Nginx Cache Module Configuration Summary proxy_cache (not finished)

Source: Internet
Author: User

Introduction: This cache setting uses the third-party module purge, the use of the source link and access to the specific content between the keyword "/purge/" can be added.

Such as: access to Http://192.168.0.1/a.png will generate a.png cache files;

You can erase the generated cache as long as you pass the http://192.168.0.1/purge/a.png.

First, get the installation package

Get the installation package: wget http://nginx.org/download/nginx-1.7.9.tar.gz

Get Cache cleanup module: wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz

Second, install Nginx

[email protected]]# tar -xvzf nginx-1.7. 9. Tar . Gz[[email protected]]# tar -zxvf ngx_cache_purge-2.3. Tar . gz
[Email protected]]# cd nginx-1.7. 9 [email protected]]#. /configure--prefix=/usr/local/nginx \--add-module=. /ngx_cache_purge-2.3[[Email protected]]# make
[[Email protected]]# make install

Third, the configuration nginx (mainly add bold font part)

[Email protected]]cd/usr/local/nginx [[email protected]]vi. /conf/nginx.conf

Replace the original part with a bold font

Worker_processes  1;  Events {    worker_connections  ;} HTTP {    include       mime.types;    Default_type  application/octet-stream;  Proxy_read_timeout, Proxy_send_timeout 5, Proxy_buffer_size 16k; proxy_buffers 4 64k; proxy_busy_buffers_ Size 128k; Proxy_temp_file_write_size 128k; Proxy_temp_path/home/mpeg/cache_n/temp; Proxy_cache_path/home/mpeg/cache_n levels=1:2 keys_zone=content:20m inactive=1d max_size=100m; Keepalive_timeout;
server {
Listen 8055; server_name localhost; location / {302 304 206 24h; Proxy_cache_valid any 1d; Proxy_set_header Host $host; Proxy_set_header x-forwarded-for$remote _addr; proxy_cache_key $host $uri$is_args$args; proxy_pass/http/ 192.168.0.1:80;   ~/pure (/.*) {Allow 192.0.0.0/24, deny all, Proxy_cache_purge content $host $host$1 $is _   Args$args; }
Error_page 502 503 504/50x.html; location =/50x.html {root html;}  }}

Iv. description

/********************************************* This paragraph is a comment:----------------------------------------------client_body_    Buffer_size 512k;    Proxy_connect_timeout 10;    Proxy_read_timeout 180;    Proxy_send_timeout 5;    Proxy_buffer_size 16k;    Proxy_buffers 4 64k;    Proxy_busy_buffers_size 128k;    Proxy_temp_file_write_size 128k;   Proxy_temp_path/home/mpeg/cache_n/temp;   This is the temporary cache file storage path Proxy_cache_path/home/mpeg/cache_n levels=1:2 keys_zone=content:20m inactive=1d max_size=100m;            This path is the cache path of the final real file keepalive_timeout;-------------------------------------------------------location/{            Proxy_cache content;    Proxy_cache_valid 302 304 206 24h;            You want to cache the HTTP status codes and their cache time proxy_cache_valid any 1d;            Proxy_set_header Host $host;             Proxy_set_header x-forwarded-for $remote _addr;  Proxy_cache_key $host $uri$is_args$args;        The naming rules for cache files Proxy_pass http://192.168.0.1:80; The server address of the Nginx proxy}---------------------------------------------------------Location ~/pure (/.*) {//This location is mainly the U             The link in RL with/pure/is filtered out and then executes the third-party cleanup cache module that we just installed.             Allow 192.0.0.0/24;             Deny all;        Proxy_cache_purge content $host $host$1$is_args$args; }**********************************************

  

Nginx Cache Module Configuration Summary proxy_cache (not finished)

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.