search

Home  >  Q&A  >  body text

Https access nginx, how to redirect an http address

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

高洛峰高洛峰2759 days ago1143

reply all(6)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-06-24 09:46:27

    Reverse proxy is not enough

    server{
        listen 443;
        location / { 
           proxy_pass http://my_node_app; 
        }
     }   

    reply
    0
  • 迷茫

    迷茫2017-06-24 09:46:27

    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

    reply
    0
  • 大家讲道理

    大家讲道理2017-06-24 09:46:27

    Why don’t you provide https protocol directly

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-24 09:46:27

    You can listen to port 443, and then redirect in this listening == Haha, I guess, I have never done this. . .

    reply
    0
  • 三叔

    三叔2017-06-24 09:46:27

    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;
      }
    }

    reply
    0
  • 为情所困

    为情所困2017-06-24 09:46:27

    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.

    reply
    0
  • Cancelreply