nginx分发gateway集群和nacos集群https配置

zhx1994
zhx1994 2019-10-14 23:07
阅读需:0


user  root;

worker_processes  8;


error_log  /var/log/nginx/error.log warn;

pid        /var/run/nginx.pid;


worker_rlimit_nofile 65535;


events {

  use epoll;

  worker_connections 65535;

  accept_mutex off;

  multi_accept off;

}



http {

    include       /etc/nginx/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  /var/log/nginx/access.log  main;

    

    #limit_conn_zone定义每个IP的并发连接数量

    #设置一个缓存区保存不同key的状态,大小10m。使用$limit来作为key,以此限制每个源IP的链接数

    limit_req_zone $binary_remote_addr zone=one:100m rate=10r/s;

    limit_conn_zone $binary_remote_addr zone=addr:10m

    sendfile        on;

    #tcp_nopush     on;


    keepalive_timeout  65;


    #gzip  on;


    #include /etc/nginx/conf.d/*.conf;


    upstream gatewayServer {

             ip_hash;

             server 172.18.38.233:8200;

             server 172.18.177.223:8200;

             server 172.18.177.222:8200;

             server 172.18.122.119:8200;

             keepalive 20000;

    }


   upstream nacosserver{

        ip_hash;

        server 172.18.38.233:8848;

        server 172.18.177.223:8848;

        server 172.18.177.222:8848;

        #server 172.18.122.119:8848;

    }


    server {

        listen       80;

        server_name  yd.xyd488.com;

        limit_req zone=one burst=20 nodelay;

         #    ssl_protocols  SSLv2 SSLv3 TLSv1;

    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

    #    ssl_prefer_server_ciphers   on;

    location / {

           proxy_set_header X-Real-IP $remote_addr;

           proxy_set_header Host $http_host;

           proxy_set_header X-Nginx-Proxy true;

           proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;

           proxy_redirect off;

           limit_conn addr 5;

           ### 指定上游服务器负载均衡服务器

           # add_header backendIP $upstream_addr;

           proxy_pass http://gatewayServer/;

           #proxy_set_header X-Real-IP $remote_addr;

           #proxy_set_header Host $host:$server_port;

    }

    }

    server {

        listen       8858;

        server_name  nacos;

        location /nacos/ {

            proxy_pass http://nacosserver/nacos/;

        }

    }


   ###

   # HTTPS server configuration

   ###

   server {

    listen       443 ssl;

    server_name  yd.xyd488.com;


    ssl                on;

    #证书和密钥存放地址

    ssl_certificate      /etc/nginx/server.pem;

    ssl_certificate_key  /etc/nginx/server.key;


    ssl_session_timeout  5m;


    #    ssl_protocols  SSLv2 SSLv3 TLSv1;

    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

    #    ssl_prefer_server_ciphers   on;

    location / {

           proxy_set_header X-Real-IP $remote_addr;

           proxy_set_header Host $http_host;

           proxy_set_header X-Nginx-Proxy true;

           proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;

           proxy_redirect off;

           limit_req zone=one burst=8000 nodelay;

           ### 指定上游服务器负载均衡服务器

           # add_header backendIP $upstream_addr;

           proxy_pass http://gatewayServer/;

           #proxy_set_header X-Real-IP $remote_addr;

           #proxy_set_header Host $host:$server_port;

    }

  }

}

评论
  • 消灭零回复