使用带 SSL 的 Nginx,在 Ubuntu 上正确使用端口 8080 的参考网站
Reference Website Properly w/ port 8080 on Ubuntu using Nginx with SSL
大家好,
我正在尝试在 ubuntu 16.04 上发布我的示例 ASP.NET 核心应用程序,代理服务器是 Nginx。
我的服务器有 LetsEncript 提供的 SSL 证书,一切正常。但是当我尝试使用服务于示例端口 8080 的 Web 应用程序时,它不起作用并且 nginx 页面仍然显示,即使我已经在默认文件中注释掉它。
server {
if ($host = www.mywebsite.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = mywebsite.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
}
server_name mywebsite.com www.mywebsite.com;
return 404; # managed by Certbot
}
(出于隐私原因,我需要不透露确切的域名)
顺便说一下,我的真实域工作正常并且 localhost:8080 在服务器内 运行 正常。
您必须在服务器 {} 内声明您的位置,其中包含 443。
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/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
保存你的默认文件然后重启你的 nginx
sudo systemctl restart nginx
大家好,
我正在尝试在 ubuntu 16.04 上发布我的示例 ASP.NET 核心应用程序,代理服务器是 Nginx。
我的服务器有 LetsEncript 提供的 SSL 证书,一切正常。但是当我尝试使用服务于示例端口 8080 的 Web 应用程序时,它不起作用并且 nginx 页面仍然显示,即使我已经在默认文件中注释掉它。
server {
if ($host = www.mywebsite.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = mywebsite.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
}
server_name mywebsite.com www.mywebsite.com;
return 404; # managed by Certbot
}
(出于隐私原因,我需要不透露确切的域名)
顺便说一下,我的真实域工作正常并且 localhost:8080 在服务器内 运行 正常。
您必须在服务器 {} 内声明您的位置,其中包含 443。
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/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
保存你的默认文件然后重启你的 nginx
sudo systemctl restart nginx