windows nginx 搭建 图片服务器

windows   nginx   搭建  图片服务器   

配置如下:

#user  nobody;
worker_processes  2;  

#错误日志存放路径  
#error_log  logs/error.log;  
#error_log  logs/error.log  notice;  
error_log   logs/error.log  info; 

#指定pid存放文件  
pid        logs/nginx.pid; 


events {  
    #使用网络IO模型linux建议epoll,FreeBSD建议采用kqueue,window下不指定。  
    #use epoll;  
      
    #允许最大连接数  
    worker_connections  2048;  
} 


http {  
    include       mime.types;  
    default_type  application/octet-stream;  
  
        #定义日志格式  
    #log_format  main  '$remote_addr - $remote_user [$time_local] $request '  
    #                  '"$status" $body_bytes_sent "$http_referer" '  
    #                  '"$http_user_agent" "$http_x_forwarded_for"';  
  
    #access_log  off;  
    access_log  logs/access.log;  
  
    client_header_timeout  3m;  
    client_body_timeout    3m;  
    send_timeout           3m;  
   
    client_header_buffer_size    1k;  
    large_client_header_buffers  4 4k;  
  
    sendfile        on;  
    tcp_nopush      on;  
    tcp_nodelay     on;  
  
    #keepalive_timeout  75 20;  
  
    include    gzip.conf;  
   
  

	# windows 文件服务器配置
	server {
        listen       8089;#端口号
        server_name  localhost;#本机

        charset utf-8;

        #access_log  logs/host.access.log  main;

	location ~ .*\.(gif|jpg|jpeg|png)$ {
	    expires 24h;
            root E:/resourcesfile/images/;#指定图片存放路径
            access_log E:/resourcesfile/img_nginx.log;#图片路径
            proxy_store on;
            proxy_store_access user:rw group:rw all:rw;
            proxy_temp_path         E:/resourcesfile/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:8089;#代理访问地址
            }
	}

        location / {
            root   html;
            index  index.html index.htm;

        }
        error_page  404              /404.html;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }



    }
}

在  

E 盘 创建  resourcesfile/images/   文件夹   里面放图片

         创建日志   resourcesfile/img_nginx.log     

访问  地址  是  127.0.0.1:8089/xxxx.jpg

可以   联合  反向代理使用



猜你喜欢

转载自blog.csdn.net/zsm136767349700/article/details/53746084