【问题标题】:Reference Website Properly w/ port 8080 on Ubuntu using Nginx with SSL在使用 Nginx 和 SSL 的 Ubuntu 上正确使用端口 8080 参考网站
【发布时间】:2018-04-27 06:48:20
【问题描述】:

大家好,

我正在尝试在 ubuntu 16.04 上发布我的示例 ASP.NET Core 应用程序,代理服务器是 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
}

Full default file

(由于隐私,我需要不透露确切的域名)

顺便说一句,我的真实域工作正常,并且 localhost:8080 在服务器内正常运行。

【问题讨论】:

    标签: ssl nginx .net-core ssl-certificate certbot


    【解决方案1】:

    您必须在服务器 {} 中声明您的位置,其中包含 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

    【讨论】:

      猜你喜欢
      • 2013-10-07
      • 1970-01-01
      • 2021-10-01
      • 2012-10-18
      • 1970-01-01
      • 2020-07-05
      • 1970-01-01
      • 1970-01-01
      • 2023-03-02
      相关资源
      最近更新 更多