nginx 配置

来源:互联网 发布:网络舆论的特点 编辑:程序博客网 时间:2024/06/01 10:45
user web;

worker_processes  12;
worker_cpu_affinity 000000000001 000000000010 000000000100 000000001000 000000010000 000000100000 000001000000 000010000000 000100000000 001000000000 010000000000 100000000000;

error_log  logs/error.log  notice;

pid        logs/nginx.pid;

worker_rlimit_nofile 512000;

events {
    use epoll;
    worker_connections  20480;
}

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

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

    log_format redirect_fmt '[$time_local] $cookie_id $remote_addr $request '
                        '$status $body_bytes_sent "$http_referer" '
                        '$upstream_addr $upstream_status $upstream_response_length '
                        '$upstream_response_time $request_time';


    access_log  logs/access.log  main;
#    access_log on;
#    error_log on;
    #sendfile        on;
    keepalive_timeout  300;
    gzip on;

        upstream gadget.talk.xiaonei.com  {
          #server 10.3.18.37:8000;
         server 10.3.25.221:8000;
        server 10.3.18.78:8000;
        server 10.3.18.79:8000;
    }
        upstream gadget.talk.renren.com  {
          #server 10.3.18.37:8000;
        server 10.3.25.221:8000;
        server 10.3.18.78:8000;
        server 10.3.18.79:8000;
    }

    upstream wpi  {
                server 10.3.18.32:80;
                server 10.3.18.33:80;
                server 10.3.18.34:80;
                server 10.3.18.35:80;
                server 10.3.18.36:80;
        }

        upstream notepadgates {
                #server 10.3.17.123:10000;
                server 10.3.19.171:10000;
                server 10.3.17.122:10000;
        }

    upstream redirects {
                #server 10.3.17.121:19000;
                server 10.3.24.163:19000;
                server 10.3.24.164:19000;
                #server 10.3.19.171:19000;
                #server 10.3.19.172:19000;
    }

    upstream rrgame_servers {
                server 10.3.18.78:8080;  #t12
                server 10.3.23.44:8080;  #t42
    }

    upstream ugc_photo_servers {
                server 10.3.25.31:8180;
                server 10.3.25.32:8180;
                server 10.3.25.33:8180;
                server 10.3.25.34:8180;
                server 10.3.25.35:8180;
                server 10.3.25.36:8180;
                server 10.3.25.37:8180;
                server 10.3.25.38:8180;
                server 10.3.25.39:8180;
                server 10.3.25.40:8180;
    }

    server {
        listen  80;
        server_name    gadget.talk.xiaonei.com;
    fastcgi_buffers 8 128k;
        location  ~redirect\.do {
            access_log  logs/xn_redirect.log redirect_fmt;
                include      fastcgi_params;
                fastcgi_pass redirects;

                add_header Cache-Control no-cache;
                add_header Pragma no-cache;
                add_header Expires 'Thu, 01 Jan 1970 00:00:00 GMT';
    }
    
        location  ~\.do.*$ {
#               # root    /bigpool;
                #expires      365d;
                proxy_pass http://gadget.talk.xiaonei.com;
        }

    location ~toolbar.*$ {
                #expires      365d;
                proxy_pass http://wpi;
        }
    }

    server {
        listen  80;
        server_name    notepad;

        location /notepad/ {
                root   html;
                index  /notepad/notepad.html;
        }

        location ~ /.*\.note$ {
                fastcgi_pass notepadgates;
                include      fastcgi_params;

                add_header Cache-Control no-cache;
                add_header Pragma no-cache;
                add_header Expires 'Thu, 01 Jan 1970 00:00:00 GMT';
        }
    }

    server {
        listen  80 default backlog=4196;
        server_name    gadget.talk.renren.com;
    #location / {
    #    root gadget_static;
    #}
        include   fastcgi_params;
        location  ~redirect\.do {
            access_log  logs/rr_redirect.log redirect_fmt;
                include      fastcgi_params;
                fastcgi_pass redirects;

                add_header Cache-Control no-cache;
                add_header Pragma no-cache;
                add_header Expires 'Thu, 01 Jan 1970 00:00:00 GMT';
    }
    location  ~redirects {
            access_log  logs/rr_redirect.log redirect_fmt;
                include      fastcgi_params;
                fastcgi_pass redirects;

                add_header Cache-Control no-cache;
                add_header Pragma no-cache;
                add_header Expires 'Thu, 01 Jan 1970 00:00:00 GMT';
    }

        location /passport/ {
                access_log  logs/passport.log redirect_fmt;
                include      fastcgi_params;
                fastcgi_pass redirects;
 
                add_header Cache-Control no-cache;
                add_header Pragma no-cache;
                add_header Expires 'Thu, 01 Jan 1970 00:00:00 GMT';
        }

    location /announcement/ {
        log_format announcement  'uid:$cookie_id request:$request http_referer:$http_referer '
            ' $remote_addr $remote_user [$time_local] '
            ' $status $body_bytes_sent '
            ' $http_user_agent $http_x_forwarded_for $request_body' ;

        access_log  logs/announcement.log announcement;
        fastcgi_pass 10.3.18.163:9001;
        expires -1;
    }

        location  ~\.do.*$ {
                proxy_pass http://gadget.talk.renren.com;
        }
    
    location ~toolbar.*$ {
                #expires      365d;
                proxy_pass http://wpi;
        }

        location /notepad/ {
                root   html;
                index  /notepad/notepad.html;
        }

        location /hotshare/ {
            log_format hotshare '$request $request_body'
                        ' $remote_addr $remote_user [$time_local] '
                        ' $status $body_bytes_sent '
                        ' $http_user_agent $http_x_forwarded_for';
             access_log  logs/hotshare.log hotshare;
             # proxy_pass http://10.3.18.78:8080;
             fastcgi_pass 10.3.18.78:9020;
             include      fastcgi_params;
        }

        location /hotshare/hot {
             access_log  logs/hotshare1.1.log hotshare;
             # proxy_pass http://10.3.18.78:8080;
             fastcgi_pass 10.3.18.78:9022;
             include      fastcgi_params;
        }

        location /hotshare/photolist {
             access_log  logs/hotshare1.1.log hotshare;
             # proxy_pass http://10.3.18.78:8080;
             fastcgi_pass 10.3.18.78:9022;
             include      fastcgi_params;
        }

        location /renrengame/ {
            log_format rrgame  'uid:$cookie_id request:$request http_referer:$http_referer '
                        ' $remote_addr $remote_user [$time_local] '
                        ' $status $body_bytes_sent '
                        ' $http_user_agent $http_x_forwarded_for';
            access_log  logs/renrengame.log  rrgame;
            #proxy_pass http://10.3.18.79:8080;
            proxy_pass  http://rrgame_servers;
            #expires -1;
        }

        location /photo/ {
            log_format ugc_photo  'uid:$cookie_id request:$request http_referer:$http_referer '
                        ' $remote_addr $remote_user [$time_local] '
                        ' $status $body_bytes_sent '
                        ' $http_user_agent $http_x_forwarded_for';
            access_log  logs/ugc_photo.log  ugc_photo;
            proxy_pass  http://ugc_photo_servers;
            #expires -1;
        }

        location /images/ {
            root   gadget_static;
            expires 3d;
        }   

        location /css/ {
            root   gadget_static;
            expires 3d;
        }  

        location ~ /.*\.note$ {
                fastcgi_pass notepadgates;
                include      fastcgi_params;

                add_header Cache-Control no-cache;
                add_header Pragma no-cache;
                add_header Expires 'Thu, 01 Jan 1970 00:00:00 GMT';
        }
    }
}