具有自定义端口配置的 Nginx ssl 失败
Nginx ssl with a custom port configuration fails
我有以下nginx配置
server {
listen 4050;
listen 443 ssl;
server_name url ww.url;
location / {
proxy_pass http://localhost:6091;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain/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
}
上面的内容在访问 http://domain:4050
之后的 http 上有效,但是当我通过 https://domain:4050
使用 https 访问相同内容时失败
我错过了什么才能让它在端口 4050 上使用 https。
要使其与 https 一起使用,您需要将 listen 4050;
更改为 listen 4050 ssl;
。但是你将无法将它与 http 一起使用。
You cant use the same port for both HTTP and HTTPS
我有以下nginx配置
server {
listen 4050;
listen 443 ssl;
server_name url ww.url;
location / {
proxy_pass http://localhost:6091;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain/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
}
上面的内容在访问 http://domain:4050
之后的 http 上有效,但是当我通过 https://domain:4050
我错过了什么才能让它在端口 4050 上使用 https。
要使其与 https 一起使用,您需要将 listen 4050;
更改为 listen 4050 ssl;
。但是你将无法将它与 http 一起使用。
You cant use the same port for both HTTP and HTTPS