不使用端口的 Nginx 重定向

不使用端口的 Nginx 重定向

我正在使用 nginx 将多个具有 IP:PORT 的 http 服务重定向到 https 域。现在我只需要 nginx 进行重定向:

http://IPhttps://域名并使用以下浏览器打开它: https://域名:端口因为我的服务器上有多个端口,并且希望所有内容都在同一个 SSL 域中。这可能吗?到目前为止,我所做的所有测试都失败了...

###
### PROXY CONFIG FOR bot*******.*****.de
###

    server {
    server_name bot*******.*****.de; # managed by Certbot
        root         /usr/share/nginx/default;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

     port_in_redirect off;

        location / {
          proxy_set_header        Host $http_host;
          proxy_set_header        X-Real-IP $remote_addr;
          proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header        X-Forwarded-Proto $scheme;
          proxy_pass          http://###.####.###.####;
          proxy_read_timeout  90;
          proxy_redirect      http://###.####.###.#### https://bot*******.*****.de;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/bot*******.*****.dee/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/bot*******.*****.de/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

    server {
    if ($host = bot*******.*****.de) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen       80 ;
        listen       [::]:80 ;
    server_name bot*******.*****.de;
    return 404; # managed by Certbot

}

## ENDE BOTCONF

相关内容