【发布时间】:2021-06-04 04:15:56
【问题描述】:
我正在尝试将我的 ABP 应用程序部署到 Amazon Lightsail 上的 Ubuntu 20.04 服务器。我正在使用带有 Blazor UI、EFCore 和 PostgreSQL 作为 DB 的 Abp,它在我的本地 Windows 机器上运行良好,并且带有 IIS Express。
我已关注 this Microsoft guide 将我的应用程序部署到 Ubuntu 服务器。由于 ASP Net Core 运行时安装在远程机器上,我将我的所有项目发布为framework-dependent。
到目前为止,我已经成功地在服务器上运行了 Migrator 并使用 Dataseeder 为数据库播种。我还配置了 Nginx 和 Kestrel 服务来在服务器上运行我的HttpApi.Host 项目。 (澄清一下:HttpApi.Host 运行得非常好,我可以使用 swagger 接口返回查询结果。)
我无法实现的是运行 Blazor UI。将发布的文件复制到服务器并配置 Nginx 后,根 URL 会绕过 Blazor 将我直接重定向到 swagger UI。
我试图从 Nginx 配置中删除 HttpApi.Host 并将 Blazor UI 设置为唯一的 URL(“/”),但只要 kestrel 服务运行,根 URL 就会自动重定向到 HttpApi.Host(swagger界面)。然后,我尝试停止并禁用 kestrel 服务,并希望至少能看到 index.html,但这只会给我带来 502 Bad Gateway 错误。
问题:
我基本上想在 Ubuntu 20.04 上运行我的 Blazor UI 和 HttpApi.Host。还有哪些其他步骤可以遵循?我检查了original abp docs,但没有找到任何关于在 Linux 上部署的资源。
这是我的 Nginx 配置:
server {
listen 80;
server_name example.com *.example.com;
location / {
root /home/ubuntu/myapp/Blazor;
proxy_pass http://localhost:5000;
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;
}
}
这是我的 Kestrel 配置:
[Unit]
Description=HttpApiHost .NET Web API App running on Ubuntu
[Service]
WorkingDirectory=/home/ubuntu/myapp/MyAppApi
ExecStart=/usr/bin/dotnet /home/ubuntu/myapp/MyAppApi/MyApp.HttpApi.Host.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=http-api-host-syslog
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
【问题讨论】:
标签: ubuntu nginx blazor-webassembly abp kestrel