【发布时间】:2021-04-11 14:30:53
【问题描述】:
我正在尝试提供默认的 Blazor hello world 应用 (https://dotnet.microsoft.com/learn/aspnet/blazor-tutorial/intro) 到公共互联网。 我试图通过在 Ubuntu 20.04 LTS 安装上运行 NginX 来实现这一点。
我使用命令“dotnet run”运行 hello world 应用程序。这使得应用程序在 localhost:5000 可用。 然后我使用 NginX 将任何请求传递给服务器公共 ip 到 localhost 5000。我没有加载所有文件,而是只获取原始 html 文件,不需要任何 .css 或 .js 文件。
Image: Html page without css or js files loaded
因此,当通过 localhost:5000 查看应用程序时,我得到了工作页面。 通过服务器公共 IP 查看它时,我只得到原始 html,没有 js 或 css 文件。 例如,当通过 localhost:5000/counter 查看应用程序时,会加载计数器页面。 当使用 IP/计数器通过公共互联网访问它时,什么都没有加载。
这是我在 etc/nginx/sites-available/default 下的 nginx 配置。 不确定我需要更改什么或在哪里可以找到更多信息。
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_pass http://localhost:5000/;
try_files $uri $uri/ /css /wwwroot /Shared /Services =404;
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-Forwarded-Proto $scheme;
}
【问题讨论】:
标签: c# .net ubuntu nginx blazor