конфиг

delphiworld nginx-forum на nginx.us
Ср Сен 7 12:15:14 UTC 2011


настроил nginx на отдачу статики из
файлового кэша, указал expires, при
обновлении страницы f5 возвращает 304,
при переходе по ссылкам и возврате на
страницу все равно 200
вот конфиг:

user www;
worker_processes  1;
timer_resolution 100ms;
worker_priority -5;
error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
    use epoll;
}

http {
    include       /etc/nginx/mime.types;
    #limit_req_zone $binary_remote_addr zone=ddos:10m  rate=100r/s;
    access_log	/var/log/nginx/access.log;
    proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=default:1024m
inactive=1d max_size=1024m;
    #sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_buffers 4 8k;
    gzip_comp_level 4;
    gzip_http_version 1.1;
    gzip_proxied any;
    gzip_types text/html text/plain application/xml
application/x-javascript text/css;
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
    client_max_body_size 16m;
    #log_format  isp '$bytes_sent $request_length';
    server {
		listen 62.75.216.187:80;              
		server_name site.com combats2.com www.site.com www.combats2.com;
		error_page 404 /404.html;
                location /404.html {
                internal;
                }
                proxy_intercept_errors on;
		location ~* ^/(webstat/|awstats|webmail/|myadmin/|manimg/) {
 			proxy_pass http://62.75.216.187:8080;
                        proxy_redirect off;
			proxy_set_header Host $host;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Real-IP $remote_addr;
		}
		location / {
                        #limit_req  zone=ddos burst=10;
			proxy_pass http://62.75.216.187:8080;                       
                        proxy_redirect off;
		        proxy_set_header Host $host;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Real-IP $remote_addr;
		}
		location ~* ^.+\.(jpg|jpeg|gif|png|js|css|html)$ {
                        root /var/www/www/data/www/site.com;
 			access_log off;
			expires 1d;
                        add_header Cache-Control public;
                        proxy_buffering on;
                        proxy_cache default; 
                        proxy_cache_valid  404 502 503 60m;
                        proxy_cache_valid  any 1d;
		}
	}
	server {
		listen 62.75.216.187:80;              
		server_name combats.site.com www.combats.site.com;
		rewrite ^(/manager/.*)$	https://$host$1	permanent;
		error_page 404 /404.html;
                location /404.html {
                internal;
                }
                proxy_intercept_errors on;
		location ~* ^/(webstat/|awstats|webmail/|myadmin/|manimg/) {
 			proxy_pass http://62.75.216.187:8080;
			proxy_redirect http://combats.site.com:8080/ /;
			proxy_set_header Host $host;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Real-IP $remote_addr;
		}
		location / {
                        #limit_req  zone=ddos burst=10;
			proxy_pass http://62.75.216.187:8080;
			proxy_redirect http://combats.site.com:8080/ /;
			proxy_set_header Host $host;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Real-IP $remote_addr;
		}
 		location ~* ^.+\.(jpg|jpeg|gif|png|js|css|html)$ {
                        root /var/www/www/data/www/combats.site.com;
    			access_log off;
			expires 3d;
                        add_header Cache-Control public;
                        proxy_buffering on;
                        proxy_cache default; 
                        proxy_cache_valid  404 502 503 60m;
                        proxy_cache_valid  any 1d;
		}
	}
	server {
		listen 62.75.216.187:80;
                #proxy_buffering on;
                #proxy_cache default;      
                #proxy_cache_valid  404 502 503 60m;
                #proxy_cache_valid  any 1d;
		server_name img.site.com www.img.site.com;
		rewrite ^(/manager/.*)$	https://$host$1	permanent;
		error_page 404 /404.html;
                location /404.html {
                internal;
                }
                proxy_intercept_errors on;
		location ~* ^/(webstat/|awstats|webmail/|myadmin/|manimg/) {
			proxy_pass http://62.75.216.187:8080;
			proxy_redirect http://img.site.com:8080/ /;
			proxy_set_header Host $host;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Real-IP $remote_addr;
		}
		location / {
                        #limit_req  zone=ddos burst=10;
			proxy_pass http://62.75.216.187:8080;
			proxy_redirect http://img.site.com:8080/ /;
			proxy_set_header Host $host;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Real-IP $remote_addr;
		}
		location  ~* ^.+\.(jpg|jpeg|gif|png|js|css|html)$ {
                        root /var/www/www/data/www/img.site.com;
  			access_log off;
			expires 3d;
                        add_header Cache-Control public;                
     
		}
                  proxy_buffering on;
                        proxy_cache default; 
                        proxy_cache_valid  404 502 503 60m;
                        proxy_cache_valid  any 1d;
	}

}
не знаю насколько он правильный )

Posted at Nginx Forum: http://forum.nginx.org/read.php?21,214947,214947#msg-214947



Подробная информация о списке рассылки nginx-ru