自己配的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 {

listen      443 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_cache    shared:SSL:1m;

ssl_session_timeout  5m;

ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;

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

ssl_prefer_server_ciphers  on;

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_header  X-Real-IP  $remote_addr;

proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header  Host $http_host;

proxy_max_temp_file_size 0;

proxy_http_version 1.1;

proxy_set_header Connection "";

proxy_pass  http://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_header  X-Real-IP  $remote_addr;

proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header  Host $http_host;

proxy_max_temp_file_size 0;

proxy_http_version 1.1;

proxy_set_header Connection "";

proxy_pass  http://dev-slb-open-bbs;

index index.php,index.html;

}

}

server {

listen      80;

server_name  bbs.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_header  X-Real-IP  $remote_addr;

proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header  Host $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_header  X-Real-IP  $remote_addr;

proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header  Host $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的负载均衡)