歡迎您光臨本站 註冊首頁

Nginx 配置信息

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

 Nginx 配置信息

 Nginx 配置,包括三個文件 nginx.conf, proxy.conf, gzip.confuser  nobody;
 worker_processes  2;
 
 #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  4096;
 }
 
 
 http {
     include       mime.types;
     default_type  application/octet-stream;
     server_tokens off;
 
     sendfile        on;
     #tcp_nopush     on;
 
     keepalive_timeout  65;
     limit_zone   one  $binary_remote_addr  10m;
 
     include gzip.conf;
 
     server {
         listen       80;
         server_name  localhost;
 
         location / {
             #rewrite (.*) http://www.oschina.net$1 permanent;
             deny all;
         }
 
         location ~ ^/NginxStatus {
             stub_status on;
             access_log off;
             allow   127.0.0.1;
             allow   219.136.242.37;
             allow   192.168.2.0/24;
             deny    all;
         }
 
     }
 
     server {
         listen 80;
         server_name www.oschina.net m.oschina.net my.oschina.net;
 
         log_format  oschina_log
         '$remote_addr - $remote_user [$time_local] $request '
         '"$status" $body_bytes_sent "$http_referer" '
         '"$http_user_agent" "$http_x_forwarded_for"';
         access_log  logs/oschina.log;
 
         location ~ ^/NginxStatus {
             stub_status on;
             access_log off;
             auth_basic              "valid-user";
             auth_basic_user_file  /opt/ngx/conf/oschina_pw;
         }
 
         location ~ ^/mrtg {
             auth_basic          "valid-user";
             auth_basic_user_file /opt/ngx/conf/oschina_pw;
             access_log off;
             root /opt/mrtg;
         }
 
         location ~ ^/awstats/ {
             root /data/oschina/webapp;
             access_log off;
             error_log off;
             auth_basic              "valid-user";
             auth_basic_user_file  /opt/ngx/conf/oschina_pw;
         }
 
         location ~ ^/(WEB-INF)/ {
             deny all;
         }
 
         location ~ ^/uploads/ {
             root /data/oschina/webapp;
             expires 24h;
             valid_referers none blocked *.google.com *.qq.com *.oschina.net *.csdn.net *.gzv8.com;
             if ($invalid_referer){
                 rewrite ^/ http://www.oschina.net/img/logo.gif;
             }
         }
 
         location ~ \.(htm|html|gif|jpg|jpeg|png|ico|rar|css|js|zip|txt|flv|swf|doc|ppt|xls|pdf)$ {
             root /data/oschina/webapp;
             access_log off;
             expires 24h;
         }
 
         location / {
             proxy_pass http://localhost:9081;
             include proxy.conf;
         }
 
         error_page 502 503 /502.html;
         error_page 404 /404.html;
         error_page 403 /403.html;
     }
 }

《解決方案》

 

  [代碼] proxy.conf
 01 proxy_redirect          off;  
 
 02 proxy_set_header        Host $host;  
 
 03 proxy_set_header        X-Real-IP $remote_addr;  
 
 04 proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;  
 
 05 client_max_body_size    10m;  
 
 06 client_body_buffer_size 128k;  
 
 07 proxy_connect_timeout   300;  
 
 08 proxy_send_timeout      300;  
 
 09 proxy_read_timeout      300;  
 
 10 proxy_buffer_size       4k;  
 
 11 proxy_buffers           4 32k;  
 
 12 proxy_busy_buffers_size 64k;  
 
 13 proxy_temp_file_write_size 64k;
 
 
 
 [代碼] gzip.conf
 1 gzip            on;  
 
 2 gzip_min_length     1000;  
 
 3 gzip_types      text/plain text/css application/x-javascript;


[火星人 ] Nginx 配置信息已經有361次圍觀

http://coctec.com/docs/service/show-post-15457.html