本文实例为大家分享了Nginx代理输出缩放图片的具体代码,供大家参考,具体内容如下

nginx 配置文件:
# document ppt convert Configuration.
upstream document.polyv.net {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name document.polyv.net;
index index.html index.htm;
charset utf-8;
client_max_body_size 1000m;
# ignore favicon.ico not exist.
location = /favicon.ico {
log_not_found off;
access_log off;
}
# not allow to visit hidden files.
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location / {
if ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$) {
add_header Content-Disposition: 'attachment;';
add_header Content-Type: 'APPLICATION/OCTET-STREAM';
}
proxy_pass http://document.polyv.net;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REQUEST_HOST $host;
# include proxy.conf;
charset UTF-8;
}
# user upload files
location /images/ {
#expires 7d;
alias /data03/ovp/blobs/;
proxy_store on;
proxy_store_access user:rw group:rw all:rw;
proxy_set_header Accept-Encoding "";
if ( !-f $request_filename ) {
proxy_pass http://document.polyv.net;
}
}
location /blobs/ {
#expires 7d;
alias /data03/ovp/blobs/;
}
location /preview/images/ {
#expires 7d;
alias /data03/ovp/blobs/;
proxy_store on;
proxy_store_access user:rw group:rw all:rw;
proxy_set_header Accept-Encoding "";
if ( !-f $request_filename ) {
proxy_pass http://document.polyv.net;
}
}
}
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。