Nginx reverse proxy and cache and cache cleanup

Source: Internet
Author: User
Tags nginx reverse proxy

Nginx reverse proxy and cache and cache cleanup

Original address: http://www.cnblogs.com/caoguo/p/5012447.html

One. Nginx Configuration

#user nobody;worker_processes1; #error_log logs/Error.log, #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid;events {worker_connections1024x768;} HTTP {log_format main'$remote _addr-$remote _user [$time _local] "$request"'                      '$status $body _bytes_sent "$http _referer"'                      '"$http _user_agent" "$http _x_forwarded_for "'              '$upstream _addr $upstream _status $request _time $upstream _response_time'; Access_log/var/log/nginx/Access.log Main; Error_log/var/log/nginx/Error.log;    Server_tokens off;    Include Mime.types; Default_type Application/octet-stream;    Sendfile on;    Tcp_nopush on;    Client_max_body_size 10m;    Client_body_buffer_size 128k; Proxy_connect_timeout -; Proxy_send_timeout -; Proxy_read_timeout -;    Proxy_buffer_size 64k; Proxy_buffers4512k;    Proxy_busy_buffers_size 512k;    Proxy_temp_file_write_size 512k; Proxy_temp_path/data/nginx/proxy_temp; Proxy_cache_path/data/nginx/proxy_cache levels=1:2keys_zone=cache_one:2000m inactive=3d max_size=500g;    Proxy_redirect off;    Proxy_set_header Host $host; Proxy_set_header X-real-IP $remote _addr; Proxy_set_header X-forwarded-For $proxy _add_x_forwarded_for;    gzip on;    Gzip_min_length 1k; Gzip_buffers416k; Gzip_http_version1.1; Gzip_comp_level2; Gzip_types text/plain Application/x-javascript text/css application/XML;    Gzip_vary on; Upstream Go {server www.cnblogs.com: theweight=4; #server42.121.252.58: theweight=4; } Server {Listen192.168.55.133: the;            #server_name www.cnblogs.com; Access_log/var/log/nginx/Go.access.log Main; Error_log/var/log/nginx/Go.error.log error; Location/{Proxy_cache cache_one; #proxy_cache_valid $ 304 301 3022h;                    #proxy_cache_valid any 2h;                    #expires 1d; Add_header X-Cache $upstream _cache_status; Proxy_pass http://go;Proxy_cache_key $uri $is_args$args; } Location~/purge (/.*) { allow127.0.0.1; allow192.168.55.0/ -;               Deny all; Proxy_cache_purge Cache_one $1$is _args$args; }    }}

Two. Testing

1. First visit

2. Refresh once, that is, the second visit

3. Cache cleanup

Nginx reverse proxy and cache and cache cleanup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.