首页 > 其他 > 详细

nginx

时间:2019-05-31 20:51:28      阅读:112      评论:0      收藏:0      [点我收藏+]


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


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"‘;

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;



   upstream mycluster{
       server 172.21.50.43:8000 weight=5 max_fails=1 fail_timeout=600s;
       server 172.21.50.49:8000 weight=5 max_fails=1 fail_timeout=600s;
       ip_hash;
     }
upstream mycluster1{
       server 172.21.50.43:5600 weight=5 max_fails=1 fail_timeout=600s;
       server 172.21.50.49:5600 weight=5 max_fails=1 fail_timeout=600s;
       ip_hash;
     }
upstream mycluster2{
       server 172.21.50.43:5610 weight=5 max_fails=1 fail_timeout=600s;
       server 172.21.50.49:5610 weight=5 max_fails=1 fail_timeout=600s;
       ip_hash;
     }
upstream messageServer{
       server 172.21.50.43:5650 weight=5 max_fails=1 fail_timeout=600s;
       server 172.21.50.49:5650 weight=5 max_fails=1 fail_timeout=600s;
     }

    server {
        listen       8000;
        server_name  iodstest.gicp.net;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #将访问请求转向至服务器集群,mycluster和上面upstream mycluster 对应
            proxy_pass  http://mycluster;
            port_in_redirect off;
            #proxy_set_header Host $host:$server_port;
           # 真实的客户端IP
           #proxy_set_header   X-Real-IP        $remote_addr;
            # 请求头中Host信息
            #proxy_set_header   Host             $host;
            #proxy_set_header Host $proxy_host;
            # 代理路由信息,此处取IP有安全隐患
            #proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            # 真实的用户访问协议
            #proxy_set_header   X-Forwarded-Proto $scheme;
        
            proxy_connect_timeout 5;
            proxy_read_timeout 5;
            proxy_send_timeout 5;
        }
       

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache‘s document root
        # concurs with nginx‘s one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    server {
        listen       8000 default_server;
        #server_name  172.21.50.37;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #将访问请求转向至服务器集群,mycluster和上面upstream mycluster 对应
            proxy_pass  http://mycluster;
            #proxy_set_header Host $host:$server_port;
           # 真实的客户端IP
           #proxy_set_header   X-Real-IP        $remote_addr;
            # 请求头中Host信息
            #proxy_set_header   Host             $host;
            #proxy_set_header Host $proxy_host;
            # 代理路由信息,此处取IP有安全隐患
            #proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            # 真实的用户访问协议
            #proxy_set_header   X-Forwarded-Proto $scheme;
            proxy_connect_timeout 5;
            proxy_read_timeout 5;
            proxy_send_timeout 5;
        }
       

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache‘s document root
        # concurs with nginx‘s one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    server {
        listen       5600;
        #server_name  172.21.50.37;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #将访问请求转向至服务器集群,mycluster和上面upstream mycluster 对应
            proxy_pass  http://mycluster1;
            #proxy_set_header Host $host:$server_port;
           # 真实的客户端IP
            proxy_set_header   X-Real-IP        $remote_addr;
            # 请求头中Host信息
          #  proxy_set_header   Host             $host;
            # 代理路由信息,此处取IP有安全隐患
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            # 真实的用户访问协议
            proxy_set_header   X-Forwarded-Proto $scheme;
            proxy_connect_timeout 5;
            proxy_read_timeout 5;
            proxy_send_timeout 5;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache‘s document root
        # concurs with nginx‘s one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

 server {
        listen       5650;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #将访问请求转向至服务器集群,mycluster和上面upstream mycluster 对应
            proxy_pass  http://messageServer;
            #proxy_set_header Host $host:$server_port;
           # 真实的客户端IP
           # proxy_set_header   X-Real-IP        $remote_addr;
            # 请求头中Host信息
          #  proxy_set_header   Host             $host;
            # 代理路由信息,此处取IP有安全隐患
            #proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            # 真实的用户访问协议
           # proxy_set_header   X-Forwarded-Proto $scheme;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache‘s document root
        # concurs with nginx‘s one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    server {
        listen       5610;
        #server_name  172.21.50.37;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #将访问请求转向至服务器集群,mycluster和上面upstream mycluster 对应
            proxy_pass  http://mycluster2;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            #proxy_set_header Host $host:$server_port;
           # 真实的客户端IP
          #  proxy_set_header   X-Real-IP        $remote_addr;
            # 请求头中Host信息
           # proxy_set_header   Host             $host;
            # 代理路由信息,此处取IP有安全隐患
          #  proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            # 真实的用户访问协议
          #  proxy_set_header   X-Forwarded-Proto $scheme;
         proxy_connect_timeout 5;
            proxy_read_timeout 5;
            proxy_send_timeout 5;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache‘s document root
        # concurs with nginx‘s one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

nginx

原文:https://www.cnblogs.com/qook/p/10957197.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!