Nginx Cache Configuration

Source: Internet
Author: User

Yum -y install zlib-devel pcre-devel openssl-develtar –xvf ngx_cache_ purge-1.4.tar.gztar –xvf nginx-1.0.11.tar.gzcd nginx-1.0.11/ ./configure --prefix=/ Usr/local/nginx --add-module=. /ngx_cache_purge-2.3 --with-http_stub_status_module --with-http_ssl_module --with-http_flv_ module --with-http_gzip_static_module make && make installvi /usr/local/ nginx/conf/nginx.confuser nobody;worker_processes 8;error_log /data/logs/error.log crit; events {worker_connections 1024;} Http {include mime.types;default_type application/octet-stream;charset utf-8;server_names_ hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k; Client_max_body_size 300m;tcp_nopush on;tcp_nodelay on;client_body_buffer_size 512k;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;sendfile on;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;proxy_temp_path /data/proxy_temp_dir; proxy_cache_path /data/proxy_cache_dir levels=1:2 keys_zone=cache_one:50m inactive=1m  max_size=2g;upstream real_server_pool{server 192.168.200.148:80 weight=1 max_fails=2  fail_timeout=30s;server 192.168.10.251:80 weight=1 max_fails=2 fail_timeout=30s;} Keepalive_timeout 65;server {listen 80;server_name localhost;location / {root  html;index index.html index.htm;proxy_next_upstream http_502 http_504 error  timeout invalid_header;proxy_cache cache_one;proxy_cache_valid 200 304 12h;proxy_cache_key  $host $uri$is_args$ args;proxy_set_header host  $host;p roxy_set_header x-forwarded-for  $remote _addr;proxy_pass  http://real_server_pool;expires 1d;} error_page 500 502 503 504 /50x.html;location = /50x.html {root  html;}  php scripts to apache listening on 127.0.0.1:80location ~ .*\. (php|jsp|cgi)?${proxy_set_header host  $host;p roxy_set_header x-forwarded-for  $remote _addr; Proxy_pass http://real_server_pool;}} log_format access  ' $remote _addr --  $remote _user -- [$time _local] --  "$ Request " --           $status  --  $body _bytes_sent  --  "$http _referer"  --  '          ' $http _user_agent " --  $http _x_forwardeD_for ';         access_log logs/access.log access;} 


Nginx Cache Configuration

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.