upstream webservers { ip_hash ; server 192.168.122.10:88 max_fails=3 fail_timeout=3s weight=2 ; server 192.168.122.20:88 max_fails=3 fail_timeout=3s weight=2 ; } server { listen 80 ; server_name localhost ; access_log /var/log/nginx/web01.access.log main; location / { proxy_redirect off; proxy_pass http://webservers ;
proxy_cache shmcache; proxy_cache_valid 200 302 1d; proxy_cache_valid 404 1h; proxy_cache_valid any 10m; proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
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_next_upstream error timeout invalid_header http_500 http_502 http_504; } location /status { stub_status on; access_log off; allow 192.168.122.0/24; } } server { listen 192.168.122.10:88; server_name localhost; root /usr/share/nginx/html; index index.html index.htm index.php; #charset koi8-r; location / { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?q=$1 last; } } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { #try_files $uri = 404; fastcgi_pass 127.0.0.1:9000; #fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_buffer_size 128k; fastcgi_buffers 256 16k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_read_timeout 240; include fastcgi_params; } if ($fastcgi_script_name ~ \..*\/.*php) { return 403; } # deny access to hiden file . (filename begin with ".") location ~ /\. { access_log off; log_not_found off; deny all; } # deny access to bakup file .(any filename end with "~" ) location ~ ~$ { access_log off; log_not_found off; deny all; } # cache image file location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml|swf)$ { expires 1d; } # don't log robots and favion location = /robots.txt { access_log off; log_not_found off; } location = /favicon.ico { access_log off; log_not_found off; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } } |