自己配的nginx的https的负载均衡

可能不是太好,不过勉强可以用

upstream dev-slb-open-bbs {

ip_hash;
server 10.10.10.11:8080 weight=10;
server 10.10.10.10:8080 weight=10;
keepalive 200;
}
server {
listen443 ssl;
server_name bbs.cloud.cn;
ssl on;
ssl_certificate/usr/local/nginx/ssl/1__.crt; #证书文件
ssl_certificate_key/usr/local/nginx/ssl/2__.key; #证书文件
ssl_session_cacheshared:SSL:1m;
ssl_session_timeout5m;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphersALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_cipherson;
proxy_redirect off;
location / {
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Authorization,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
return 200;
}
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_headerHost $http_host;
proxy_max_temp_file_size 0;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_passhttp://dev-slb-open-bbs/newbbs;
index index.php,index.html;
}
location ^~ /newbbs {
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Authorization,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
return 200;
}
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_headerHost $http_host;
proxy_max_temp_file_size 0;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_passhttp://dev-slb-open-bbs;
index index.php,index.html;
}
}
server {
listen80;
server_namebbs.cloud.cn;
proxy_redirect off;

location/ {
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Authorization,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
return 200;
}
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_headerHost $http_host;
proxy_max_temp_file_size 0;
proxy_http_version 1.1;
proxy_set_header Connection "";
rewrite ^(.*)$https://$host$1 permanent;
index index.php,index.html;
}
location ^~ /newbbs {
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Authorization,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
return 200;
}
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_headerHost $http_host;
proxy_max_temp_file_size 0;
proxy_http_version 1.1;
proxy_set_header Connection "";
rewrite ^(.*)$https://$host$1 permanent;
index index.php,index.html;
}
【自己配的nginx的https的负载均衡】}

    推荐阅读