
正文
Nginx 配置为https服务器
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
本机作为https服务器
server {
listen ssl;
server_name localhost; ssl_certificate ssl/server.crt;
ssl_certificate_key ssl/server.key;
ssl on;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on; location / {
root html;
index index.html index.htm;
}
}
https转发到其他机器的http端口
# HTTPS server
#
server {
listen ssl;
server_name localhost; ssl_certificate ssl/server.crt;
ssl_certificate_key ssl/server.key;
ssl on;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; location / {
#root html;
#index index.html index.htm;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://192.168.0.105/;
}
}
80端口强制跳转https
server {
listen 192.168.1.111:;
server_name test.com; rewrite ^(.*)$ https://$host$1 permanent;
}






