nginx+Ngx_cache_purge配置笔记

nginx + Ngx_cache_purge

前端的nginx配置与后端差不多,主要是编译安装的时候添加cache模块,基础看后端安装,不多介绍了

1,先解压nginx 和 Ngx_cache_purge,主要不同是安装的时候添加了ngx_cache_purge模块

[root@Nginx-C opt]# tar zxf ngx_cache_purge-2.0.tar.gz 
[root@Nginx-C opt]# tar zxf nginx-1.4.3.tar.gz 
[root@Nginx-C opt]# cd nginx-1.4.3
[root@Nginx-C nginx-1.4.3]# ./configure --user=www --group=www --add-module=../ngx_cache_purge-2.0 --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module
[root@Nginx-C nginx-1.4.3]# make && make install

2,配置主配置文件 nginx.conf

user  nginx;
worker_processes  4;


error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;


pid        logs/nginx.pid;




events {
    use epoll;
    worker_connections  65535;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    charset  utf-8;


    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';


    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    limit_conn_zone $binary_remote_addr zone=addr:10m;
    client_max_body_size 300m;
    server_tokens off;
    fastcgi_intercept_errors on;
    sendfile        on;
    tcp_nopush     on;
    keepalive_timeout  60;
    tcp_nodelay on;
    client_body_buffer_size  512k;


    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_connect_timeout    5;
    proxy_read_timeout       60;
    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   /opt/app/nginx/proxy_temp;
    proxy_cache_path  /opt/app/nginx/proxy_cache levels=1:2   keys_zone=cache_one:200m inactive=1d max_size=30g;


    gzip  on;
    gzip_min_length     1k;
    gzip_buffers        4 16k;
    gzip_http_version   1.1;
    gzip_comp_level 2;
    gzip_types  text/plain application/x-javascript text/css application/xml;
    gzip_vary on;

    server {
         listen  80;
         server_name  download03.pcjoy.cn;
         index index.html index.htm index.php;
         error_page 500 502 503 504 = /error.html;
         error_page 403 404 = /error.html;
         #rewrite     ^   https://$server_name$request_uri? permanent;
         location /{
                root /home/download03.pcjoy.cn/download/;
                #limit_conn addr 2;
                #limit_rate 2048k;
                   }
          }


}

你可能感兴趣的:(linux)