Nginx 정적 파일 캐 시 설정

1799 단어 LinuxNginx
upstream web.com {
    server 10.10.0.62 weight=1;
    server 10.10.0.63 weight=1;
}

proxy_cache_path  /var/www/web/output_cache levels=1:2 keys_zone=output:100m inactive=1d max_size=10g;
server {
    listen       80;
    server_name  10.10.0.63;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;
    root         /var/www/web/output;

    location / {
    #    index index.html;
        proxy_pass http://web.com;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        #   Web       X-Forwarded-For      IP
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        #            ,  。
        proxy_set_header Host $host;
        client_max_body_size 10m; #                
        client_body_buffer_size 128k; #                  ,
        proxy_connect_timeout 90; #nginx            (      )
        proxy_send_timeout 90; #           (      )
        proxy_read_timeout 90; #     ,         (      )
        proxy_buffer_size 4k; #       (nginx)             
        proxy_buffers 4 32k; #proxy_buffers   ,     32k     
        proxy_busy_buffers_size 64k; #        (proxy_buffers*2)
        proxy_temp_file_write_size 64k;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ {
        ##         
        proxy_ignore_headers Cache-Control;
        proxy_ignore_headers Expires;

        proxy_cache output;
        proxy_cache_valid 200 304 1d;

        proxy_cache_key $host$uri$is_args$args;
        expires 1h;

        if (-f $request_filename) {
            expires 1d;
            break;
        }
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

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

}

좋은 웹페이지 즐겨찾기