Https access nginx, how to redirect an http address
高洛峰
高洛峰 2017-06-24 09:44:27
0
6
1081

The previous section accesses an https protocol address, but the backend only provides http protocol. How to use nginx for reverse proxy?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(6)
淡淡烟草味

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!