location ~ .*\.(gif|jpg|jpeg|png)$ {
expires 24h;
root /opt/upload;
access_log /opt/nginx/logs/images.log;
proxy_store on;
proxy_store_access user:rw group:rw all:rw;
proxy_temp_path /opt/upload;
proxy_redirect off;
proxy_set_header Host 192.168.8.15;
client_max_body_size 10m;
client_body_buffer_size 1280k;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
proxy_buffer_size 40k;
proxy_buffers 40 320k;
proxy_busy_buffers_size 640k;
proxy_temp_file_write_size 640k;
}
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
5、图片路径权限
# ll /opt/
total 4
drwxr-xr-x. 3 root root 4096 Jan 31 13:08 upload
也可将upload目录设置属主为nginx用户
# chmod nginx /opt/upload
# ll /opt/
total 4
drwxr-xr-x. 3 nginx root 4096 Jan 31 13:08 upload
upload目录下pthoimanges存放图片目录属主与属组都为虚拟用户映射的本地用户(ftpuser)
#chmod -R ftpuser.ftpuser /opt/upload/pthoimanges
# ll /opt/upload/
total 4
drwxr-xr-x. 6 ftpuser ftpuser 4096 Jan 31 13:09 pthoimanges
Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx