這篇文章主要介紹了通過nginx負載均衡跳轉https的案例,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
web端拷貝證書與密鑰
scp -rp -P52113 /application/nginx/conf/key 10.0.0.5:/application/nginx/conf/
在nginx負載均衡服務端配置
vim /application/nginx/conf/nginx.conf
worker_processes 2; error_log logs/error.log; events { worker_connections 65535; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream server_pools { server 10.0.0.200:443 weight=1 max_fails=3 fail_timeout=10; #server 10.0.0.8:443 weight=1 max_fails=3 fail_timeout=10; #server 10.0.0.9:443 weight=1 max_fails=3 fail_timeout=10; } server { listen 80; server_name localhost; rewrite ^(.*)$ https://$host$1 permanent; } server { listen 10.0.0.5:443; server_name www.abc.com; #開啟 https 注意要添加在server區塊 不能在http區塊中放置 ssl on; ssl_certificate /application/nginx/conf/key/server.crt; ssl_certificate_key /application/nginx/conf/key/server.key; location / { proxy_pass https://server_pools; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } } }
#檢查nginx負載均衡配置
/application/nginx/sbin/nginx -t
#重啟nginx負載均衡
/application/nginx/sbin/nginx -s stop
/application/nginx/sbin/nginx
瀏覽器訪問測試
注意修改hosts對應的是負載均衡的IP地址信息
訪問測試
訪問結果
感謝你能夠認真閱讀完這篇文章,希望小編分享的“通過nginx負載均衡跳轉https的案例”這篇文章對大家有幫助,同時也希望大家多多支持創新互聯,關注創新互聯行業資訊頻道,更多相關知識等著你來學習!