使用带有子域的Nginx在Ubuntu上托管多个.NET应用程序

时间:2020-09-03 14:23:12

标签: .net ubuntu nginx

这是我在这里的第一篇文章,我在使用nginx在Ubuntu上托管两个内部.NET应用程序时遇到问题。我想要在子域上运行多个应用程序:

  • app1> app1.domain.com
  • app2> app2.domain.com

这是我的实际站点配置文件:

    server {
    server_name app1.domain.local;
    listen 80;
    location / {
            root /var/www/html/app1;
            proxy_pass http://localhost:5000/;
            proxy_redirect http://localhost:5000/ http://app1.domain.local;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection keep-alive;
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarder-Proto $scheme;
    }
}


server {
    server_name app2.domain.local
    listen 80;
    location / {
            root /var/www/html/app2;
            proxy_pass http://localhost:5003/;
            proxy_redirect http://localhost:5003/ http://app2.domain.local;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection keep-alive;
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarder-Proto $scheme;
    }
}
server {
    if ($host = domain.local) {
            return 301 http://$host$request_uri;
            }
    listen 80 default;
    listen [::]:80 default_server;
    server_name *.domain.local;
    return 404;
}

您能帮助我了解我需要在配置中进行哪些更改才能工作或如何对其进行调试吗?

0 个答案:

没有答案
相关问题