我正在尝试将我的 ABP 应用程序部署到 Amazon Lightsail 上的 Ubuntu 20.04 服务器。我将 Abp 与 一起使用Blazor 用户界面 , EFCore , 和 PostgreSQL 作为 DB,它在我的本地 Windows 机器上使用 IIS Express 运行得非常好。
我关注了this Microsoft guide将我的应用程序部署到 Ubuntu服务器 .由于远程计算机上安装了 ASP Net Core 运行时,我将所有项目发布为 依赖于框架 .
到目前为止,我已经设法在服务器上运行 Migrator 并使用 Dataseeder 为数据库播种。我还配置了 Nginx 和 红隼 运行我的 HttpApi.Host
的服务服务器上的项目。 (澄清一下:HttpApi.Host
运行得非常好,我可以使用 swagger 接口(interface)返回查询结果。)
我无法实现的是运行 Blazor UI。将发布的文件复制到服务器并配置 Nginx 后,根 URL 会绕过 Blazor 将我直接重定向到 swagger UI。
我试图删除 HttpApi.Host
从 Nginx 配置中并将 Blazor UI 设置为唯一的 URL(“/”),但只要 kestrel 服务运行,根 URL 就会自动重定向到 HttpApi.Host
(招摇界面)。然后,我尝试停止并禁用 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
最佳答案
由于没有确切的错误消息,我建议逐步配置您的 Linux 环境,并确保所有配置和安装都可能:
关于ubuntu - 如何将 ABP 框架应用程序部署到 Ubuntu 服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66493284/