Nginx反向代理、配置ssl证书

xiaoxiao2021-03-01  19

反向代理

配置这个的好处就是端口号本来只能唯一,但是我们通过配置就可以重定向,让我们的非80端口也能使用80端口。

server{ listen 80; server_name www.example.com:8081; location / { proxy_pass http://localhost:8081 } }

参考: http://blog.csdn.net/weixin_35884835/article/details/52588157

# # HTTPS server configuration # server { listen 443; server_name 本机的IP地址; ssl on; ssl_certificate /etc/nginx/server.crt; ssl_certificate_key /etc/nginx/server.key; ssl_session_timeout 5m; # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; # ssl_prefer_server_ciphers on; location / { #root html; #index testssl.html 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://IP地址/ssl/; } }

重启nginx,在浏览器输入:https://IP地址 会跳转到 http://IP地址/ssl/ 这个地址(后期调整为webservice接口地址即可) 重启命令 ./nginx -s reload

转载请注明原文地址: https://www.6miu.com/read-3100031.html

最新回复(0)