服务热线
135-6963-3175
配置https证书,并实现http自动转发https
在nginx.conf文件中新增配置:
server { listen 80; #增加监听https443端口 listen 443 ssl; server_name www.demo.com demo.com; #增加证书配置 ssl_certificate cert/1json.pem; ssl_certificate_key cert/1json.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; server_name_in_redirect off; error_log logs/server1.log debug; rewrite_log on; proxy_set_header Host $host:$server_port; 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; #http转发https必须加下面两项 proxy_set_header X-Forwarded-Proto https; proxy_redirect http:// https://; access_log logs/server1.access.log; location / { proxy_pass http://127.0.0.1:8081/; #index index.html index.htm; } }
nginx1.8测试通过。