【问题标题】:How to deploy ABP framework application to a Ubuntu server?如何将 ABP 框架应用程序部署到 Ubuntu 服务器?
【发布时间】:2021-06-04 04:15:56
【问题描述】:

我正在尝试将我的 ABP 应用程序部署到 Amazon Lightsail 上的 Ubuntu 20.04 服务器。我正在使用带有 Blazor UIEFCorePostgreSQL 作为 DB 的 Abp,它在我的本地 Windows 机器上运行良好,并且带有 IIS Express。

我已关注 this Microsoft guide 将我的应用程序部署到 Ubuntu 服务器。由于 ASP Net Core 运行时安装在远程机器上,我将我的所有项目发布为framework-dependent

到目前为止,我已经成功地在服务器上运行了 Migrator 并使用 Dataseeder 为数据库播种。我还配置了 NginxKestrel 服务来在服务器上运行我的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


    【解决方案1】:

    由于没有确切的错误消息,我建议逐步配置您的 Linux 环境,并确保一切都已配置和安装:

    • ASP.NET Core:在Linux上配置asp.net的资源很多,这里有一个例子http://www.projectcodify.com/hosting-aspnet-core-on-linux-using-nginx,然后确保你安装了最新的ASP.NET Core运行时
    • Blazor:部署一个简单的 Blazor Web 应用程序并确保它在服务器上运行
    • DB: 在您的简单 Blazor Web 应用程序上创建一个简单的列表页面,以确保您以正确的方式配置 DB 并且它正在工作,我更愿意从外部 DB 服务器或外部托管 PostgreSQL 服务开始,一开始只关注配置 Web 服务器组件
    • ABP 稳定上述 Web 应用程序后,您就可以部署 ABP 应用程序并发现与 ABP 本身相关的问题

    【讨论】:

    • 我可以通过在 Swagger UI 上运行我的所有查询来确认数据库和 API 都运行良好(我已经相应地更新了我的问题)。问题是,无论我的 Nginx 配置如何,我都无法从根 URL(“/”)访问 ABP Blazor UI。
    • 所以我认为你在 nginx.conf 中的问题,检查这个dev.to/helloitsm3/…
    猜你喜欢
    • 2020-01-05
    • 1970-01-01
    • 2020-05-18
    • 2016-04-30
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多