1、nginx.conf中的配置:
server {
listen 8088;
#server_name localhost;
server_name 127.0.0.1 ;
#charset koi8-r;
#charset utf-8,gbk;
charset utf-8;
location ~ .*.(gif|jpg|jpeg|png)$ {
expires 24h;
root D:\\nginx-1.23.3\\files\\images;#指定图片存放路径
access_log D:\\nginx-1.23.3\\files\\images\\img.log;#图片日志路径
proxy_store on;
proxy_store_access user:rw group:rw all:rw;
proxy_temp_path D:\\nginx-1.23.3\\files\\images;#图片路径
proxy_redirect off;
proxy_set_header Host 127.0.0.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
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;
if ( !-e $request_filename)
{
proxy_pass http://127.0.0.1:8088;
}
}
}
2 将图片放到指定的目录 D:\\nginx-1.23.3\\files\\images下
3、重启nginx :
nginx -t #检查一下nginx.conf 文件是否有错误
nginx -s reload #然后重启
4、用浏览器通过url访问图片 http://127.0.0.1:8088/girl1.png