nginx负载均衡代理配置脚本

root@kafka230:/usr/local/nginx/conf# cat nginx.conf
#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 wx_80_pools {
        server 192.168.86.231:8090 weight=1;
        server 192.168.86.232:8090 weight=1;
    }

    upstream wx_443_pools {
        server 192.168.86.231:8090 weight=1;
        server 192.168.86.232:8090 weight=1;
    }

    upstream wx_8095_pools {
        server 192.168.86.231:8090 weight=1;
        server 192.168.86.232:8090 weight=1;
    }
 server {
        listen 80;
        server_name wx.test.com;
        location / {
        proxy_pass http://wx_80_pools;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_connect_timeout 60;
        proxy_send_timeout 60;
        proxy_read_timeout 60;
        proxy_buffer_size 4k;
        proxy_buffers 4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
        }
    }
server {
        listen 443 ssl;
        server_name wx.test.com;
        ssl on;
        ssl_certificate      goumin.crt;
        ssl_certificate_key  goumin.key;
        ssl_session_timeout  5m;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers  on;
        location / {
          proxy_pass http://wx_443_pools;
          proxy_set_header Host $host;
          proxy_set_header X-Forwarded-For $remote_addr;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";}
        }

server {
        listen 8095 ssl;
        server_name wx.test.com;
        ssl on;
        ssl_certificate      test.crt;
        ssl_certificate_key  test.key;
        ssl_session_timeout  5m;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers  on;
        location / {
          proxy_pass http://wx_8095_pools;
          proxy_set_header Host $host;
          proxy_set_header X-Forwarded-For $remote_addr;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
        }
    }
}

  

posted @ 2020-08-20 20:32  BUG弄潮儿  阅读(265)  评论(0编辑  收藏  举报