nginx 负载均衡

upstream www_server {

     server xxx.xxx.xxx.xxx:8080 max_fails=3 fail_timeout=30s;

}

   

 

server {

        listen 443 ssl;

        server_name *.123456.com 123456.com;

       

        ssl_certificate           ssl/123456.com.crt;

        ssl_certificate_key       ssl/123456.com.key;

        ssl_protocols             TLSv1 TLSv1.1 TLSv1.2;

        ssl_ciphers               ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;

        ssl_prefer_server_ciphers on;

 

        location / {

            proxy_set_header Host $host;

            proxy_set_header X-Real-IP $remote_addr;

            proxy_set_header REMOTE-HOST $remote_addr;

            proxy_set_header X-Forwarded-For $remote_addr;

            proxy_pass  http://www_server;

        }

        location ~ .*\.(jpg|jpeg|gif|png|swf|css|js|txt|htc|ico)?$ {

            proxy_cache cache_one;

            proxy_cache_key $host$uri$is_args$args;

            add_header Cache "$upstream_cache_status";

            proxy_cache_valid 200 304 30m;

            proxy_cache_valid 404 500 502 503 504 3s;

            proxy_cache_valid any 1h;

            expires 2h;

            proxy_set_header Host $host;

            proxy_set_header X-Real-IP $remote_addr;

            proxy_set_header REMOTE-HOST $remote_addr;

            proxy_set_header X-Forwarded-For $remote_addr;

            proxy_pass  http://www_server;

        }

    }

备注:红色地方为需要自己更改的地方

备注:xxx.xxx.xxx.xxx 为您需要增加的后端的IP

posted @ 2018-12-29 09:23  在下刘彦直  阅读(124)  评论(0编辑  收藏  举报