nginx ip地址未重定向到域

nginx ip地址未重定向到域

我已经设置了 http -> https 重定向,如下所示,但它没有重定向http://ipaddress:5000https://subdomain.mydomain.com

    # HTTP — redirect all traffic to HTTPS
server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    return 301 https://subdomain.mydomain.com$request_uri;
}

# HTTPS — proxy all requests to the Node app
server {
    # Enable HTTP/2
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name subdomain.mydomain.com;

    # Use the Let’s Encrypt certificates
    ssl_certificate /etc/letsencrypt/live/subdomain.mydomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/subdomain.mydomain.com/privkey.pem;

    # Include the SSL configuration from cipherli.st
    include snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://localhost:5000/;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_cache_bypass $http_upgrade;
        proxy_redirect off;
    }
}

相关内容