1、Https过程
2、Nginx配置https
1)生成私钥和公钥
命令:openssl req -x509 -newkey rsa:2048 -nodes -sha256 -keyout localhost-privkey.pem -out localhost-cert.pem
2)、配置test.conf文件
server{ listen 443; server_name test.com; ssl on; ssl_certificate_key ../certs/localhost-privkey.pem; ssl_certificate ../certs/localhost-cert.pem; location / { proxy_pass http://127.0.0.1:7080; proxy_set_header Host $host; } }
3) host文件配置如下(C:\Windows\System32\drivers\etc下)
4) 使用https访问
说明已经配置成功
5) 实现访问http时,直接跳转到https
server{ listen 80 default_server; listen [::]:80 default_server; server_name test.com; return 302 https://$server_name$request_uri; } server{ listen 443; server_name test.com; ssl on; ssl_certificate_key ../certs/localhost-privkey.pem; ssl_certificate ../certs/localhost-cert.pem; location / { proxy_pass http://127.0.0.1:7080; proxy_set_header Host $host; } }
作者:Work Hard Work Smart
出处:http://www.cnblogs.com/linlf03/
欢迎任何形式的转载,未经作者同意,请保留此段声明!