开发者社区> 问答> 正文

OSS怎么使用内网地址?

ECS和OSS地址都是使用的华东1区的;OSS默认的是外网地址,上传一个图片后,用外网链接可以访问https://xswwzcy.oss-cn-hangzhou.aliyuncs.com/pgsjzqbj.gif 
换成内网链接无法访问https://xswwzcy.oss.cn-hangzhou-intemal.aliyuns.com/pgsjzqbj.gif
域名解析地址是 CNAME记录xswwzcy.oss-cn-hangzhou.aliyuncs.com

nginx配置是server {
        listen       80;
        root /www/web/tu_xingshengsz_com/public_html;
        server_name tu.xingshengsz.com;
        rewrite ^(.*)$  https://$host$1 permanent;
        index  index.html index.php index.htm;
        error_page  400 /errpage/400.html;
        error_page  403 /errpage/403.html;
        error_page  404 /errpage/404.html;
        error_page  503 /errpage/503.html;
        location ~ \.php(.*)$ {
                fastcgi_pass  unix:/tmp/php-71-cgi.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $DOCUMENT_ROOT$fastcgi_script_name;
                fastcgi_param PATH_INFO $2;
                include fcgi.conf;
        }
        location ~ /\.ht {
                deny  all;
        }
        location / {
                 try_files $uri $uri/ /?$args;
        }
}

server {
        listen       443;
        root /www/web/tu_xingshengsz_com/public_html;
        ssl                  on;
        ssl_certificate      cert/tu.xingshengsz.com.crt;
        ssl_certificate_key  cert/tu.xingshengsz.com.key;
        ssl_prefer_server_ciphers on;
        ssl_session_timeout 10m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
        server_name tu.xingshengsz.com;
        index  index.html index.php index.htm;
        error_page  400 /errpage/400.html;
        error_page  403 /errpage/403.html;
        error_page  404 /errpage/404.html;
        error_page  503 /errpage/503.html;
        location ~ \.php(.*)$ {
                fastcgi_pass  unix:/tmp/php-71-cgi.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $DOCUMENT_ROOT$fastcgi_script_name;
                fastcgi_param PATH_INFO $2;
                include fcgi.conf;
        }
        location ~ /\.ht {
             deny  all;
     }
        location / {
                 try_files $uri $uri/ /?$args;
        }
}
upstream ossproxy  {
        server oss-cn-hangzhou-internal.aliyuncs.com; #OSS的内网地址
}

server {
    listen 443;
    server_name  tu.xingshengsz.com; #ECS网站对外访问的域名

    access_log  logs/ossproxy.access.log;
    error_log  logs/ossproxy.error.log;
    root   html;
    index  index.html index.htm index.php;

    location / {
        proxy_pass  http://ossproxy;

        proxy_redirect     off;
        proxy_set_header   Host             xswwzcy.oss-cn-hangzhou-internal.aliyuncs.com;#Host要修改为OSS的域名或OSS控制台绑定的域名,否则OSS无法识别会报错
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_max_temp_file_size 0;
        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;
        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
   }
}

展开
收起
1174234673016492 2018-08-30 06:22:29 1643 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
OSS运维进阶实战手册 立即下载
《OSS运维基础实战手册》 立即下载
OSS运维基础实战手册 立即下载