拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
Reverse proxy is not enough
server{ listen 443; location / { proxy_pass http://my_node_app; } }
server { listen 80; server_name my.domain.com; [....] } server { listen 443 ssl; server_name my.domain.com; return 301 http://$server_name$request_uri; }
Simplified Nginx configuration file, the author can refer to it
Why don’t you provide https protocol directly
You can listen to port 443, and then redirect in this listening == Haha, I guess, I have never done this. . .
Use wildcards to match the corresponding route and then jump
server { # 省略部分... listen 443; server_name domain.com; # 如果后端接口格式类似这样的话 /api/users /api/login location ^~ /api/ { proxy_pass http://domain.com:12345; } }
The backend must provide https access to redirect. So you need to apply for a legal certificate and configure nginx to provide https protocol. However, there is no need to jump in this way, just add https protocol.
Reverse proxy is not enough
Simplified Nginx configuration file, the author can refer to it
Why don’t you provide https protocol directly
You can listen to port 443, and then redirect in this listening == Haha, I guess, I have never done this. . .
Use wildcards to match the corresponding route and then jump
The backend must provide https access to redirect.
So you need to apply for a legal certificate and configure nginx to provide https protocol.
However, there is no need to jump in this way, just add https protocol.