Nginx 캐 시 설정 및 nginx ngxcache_purge 모듈 사용

9004 단어 nginx캐 시ngx-cache
1. nginx 관련 의존 환경 설치
yum groupinstall "Development Tools"
yum install pcre-devel zlib-devel openssl-devel

2. ngx 다운로드cache_purge - 2.3 캐 시 모듈
wget -O /usr/src/ngx_cache_purge-2.3.tar.gz  http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
tar xfvz ngx_cache_purge-2.3.tar.gz

3. nginx 를 설치 하고 캐 시 모듈 추가
wget http://nginx.org/download/nginx-1.6.0.tar.gz
tar -xzf nginx-1.6.0.tar.gz
./configure --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-ipv6 --add-module=/usr/src/ngx_cache_purge-2.3
make && make install

4. 설치 성공 여부 확인
[root@vm10-20-10-32 ~]# nginx -V
nginx version: nginx/1.13.6
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-ipv6 --add-module=/usr/src/ngx_cache_purge-2.3

5. nginx 설정
  proxy_cache_path  /usr/local/nginx/proxy_cache_dir  levels=1:2 keys_zone=cache1:200m inactive=5m max_size=1g;
    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        location / {
            proxy_pass http://localhost.com;
        }
         location ~ /purge(/.*) {
          proxy_cache_purge cache1 $host$1$is_args$args;
         }

         location ~ .*\.html$ {
            proxy_set_header Host  $host;
            proxy_set_header X-Forwarded-For  $remote_addr;
            proxy_pass http://localhost.com;
            proxy_cache cache1; #       zone
            proxy_cache_key $host$uri$is_args$args; #     key,   、URI、     Web   Key ,Nginx  Key   ,              
            proxy_cache_valid 200 304 5m;
            access_log  logs/cache.log main;
         }

좋은 웹페이지 즐겨찾기