域名:qps.ribuncdn.cn
nginx http 配置(80端口),请求proxy 到2台server
log_format qps_access ‘ $remote_addr $time_iso8601 $server_port $request $status $http_user_agent $request_time‘; upstream qps_backend { ip_hash; server 127.0.0.1:9090; server 10.8.45.23:9090; } server { listen 80; server_name qps.ribuncdn.cn; client_max_body_size 1g; proxy_connect_timeout 300; proxy_send_timeout 300; proxy_read_timeout 300; location / { proxy_set_header Host $http_host; proxy_pass http://qps_backend; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; access_log /data/proclog/log/qps_gsvc/nginx/access.log; error_log /data/proclog/log/qps_gsvc/nginx/error.log; } }
上述基础上,加入nginx https 配置(443端口),同时需要将http重定向到https
log_format qps_access ‘ $remote_addr $time_iso8601 $server_port $request $status $http_user_agent $request_time‘; upstream qps_backend { ip_hash; server 127.0.0.1:9090; server 10.8.45.23:9090; } server { listen 80; server_name qps.ribuncdn.cn; client_max_body_size 1g; rewrite ^(.*) https://$server_name$1 permanent; #http重定向到https proxy_connect_timeout 300; proxy_send_timeout 300; proxy_read_timeout 300; location / { proxy_set_header Host $http_host; proxy_pass http://qps_backend; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; access_log /data/proclog/log/qps_gsvc/nginx/access.log; error_log /data/proclog/log/qps_gsvc/nginx/error.log; } } server { listen 443; ssl on; server_name qps.ribuncdn.cn; client_max_body_size 1g; ssl_certificate /etc/nginx/ssl/_.ribuncdn.cn.crt; #指定证书位置 ssl_certificate_key /etc/nginx/ssl/_.ribuncdn.cn.key; location / { proxy_set_header Host $http_host; proxy_pass http://qps_backend; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; access_log /data/proclog/log/qps_gsvc/nginx/access.log; error_log /data/proclog/log/qps_gsvc/nginx/error.log; } }
本文出自 “布拉君君” 博客,请务必保留此出处http://5148737.blog.51cto.com/5138737/1977553
原文:http://5148737.blog.51cto.com/5138737/1977553