![不使用端口的 Nginx 重定向](https://linux22.com/image/727866/%E4%B8%8D%E4%BD%BF%E7%94%A8%E7%AB%AF%E5%8F%A3%E7%9A%84%20Nginx%20%E9%87%8D%E5%AE%9A%E5%90%91.png)
我正在使用 nginx 将多个具有 IP:PORT 的 http 服务重定向到 https 域。现在我只需要 nginx 进行重定向:
http://IP到https://域名并使用以下浏览器打开它: 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