nginx配置
设置代理
upstream ossproxy{
server zcpcimgs.oss-cn-beijing.aliyuncs.com;
}
配置代理
server {
listen 80;
server_name zc2019.com;
location /data {
proxy_pass http://ossproxy;
proxy_redirect off;
proxy_set_header Host zcpcimgs.oss-cn-beijing.aliyuncs.com;
proxy_set_header X-Real-IP remote_addr;
proxy_set_header X-Forwarded-Forproxy_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;
}
location / {
# root html;
# index index.html index.htm;
proxy_pass http://zcjfweb;
# 真实信息
proxy_set_header Host host;
proxy_set_header X-Real-IPremote_addr;
proxy_set_header X-Forwarded-For proxy_add_x_forwarded_for;
client_max_body_size 100M;
proxy_read_timeout 30000;
proxy_send_timeout 75s;
#proxy_redirect off;
#proxy_pass_header Set-Cookie;
#proxy_hide_header X-Powered-By;
#proxy_hide_header X-Mod-Pagespeed;
#proxy_ignore_client_abort off;
#proxy_cache_valid any 10m;
#proxy_connect_timeout 75s;
#proxy_read_timeout 75s;
#proxy_send_timeout 75s;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root html;
# // proxy_pass https://www.baidu.com/;
#}
error_page 500 502 503 504 /no_server.html;
location = /no_server.html {
# root html;
proxy_pass http://127.0.0.1:88/;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php{
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scriptsfastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
#location ~ /\.ht {
# deny all;
#}
}
其他
location ^~ /resource/images/oss { proxy_pass http://bucket名.oss-cn-shenzhen-internal.aliyuncs.com; }
意思就是匹配到链接里有/resource/images/oss这样的后缀以后直接去相应的oss域名上请求资源
#配置Nginx动静分离,定义的静态页面直接从Nginx发布目录读取。