AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1509795
Accepted
xtl
xtl
Asked: 2019-12-14 05:28:26 +0800 CST2019-12-14 05:28:26 +0800 CST 2019-12-14 05:28:26 +0800 CST

ASP.NET Core 应用程序在 Ubuntu 18.04 上响应 503 Service Unavailable

  • 772

我有一个库存的、几乎未修改的 Visual Studio 模板 ASP.NET Core 应用程序,我试图在 Ubuntu 18.04 上运行。我已遵循本指南:https ://docs.microsoft.com/en-gb/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1 。

经过一段时间的打击和失踪后,我设法让 ASP.NET 服务运行。但是,当我访问我的页面时,我看到了 503 Service Unavailable 错误。

我的 Apache 配置:

<IfModule mod_ssl.c>
<VirtualHost *:80>
        ServerName example.com
        Redirect / https://example.com
        Redirect /panel https://example.com/panel
        Redirect /privacy https://example.com/privacy
</VirtualHost>

<VirtualHost *:443>
        ServerName example.com
        DocumentRoot /var/www/
        ServerAdmin [email protected]

        RewriteEngine On
        ErrorLog "/var/log/apache2/rewrite"
        LogLevel alert rewrite:trace6

        # ASP.NET application
        # launchSettings.json is configured to listen on this port
        ProxyPass /panel https://localhost:33138/
        ProxyPassReverse /panel https://localhost:33138/

        ProxyPass /api/socket ws://localhost:44909/api/socket
        ProxyPassReverse /api/socket ws://localhost:44909/api/socket

        ProxyPass /pgadmin4 !
        ProxyPass /privacy !
        ProxyPass /contact !
        ProxyPass /panel !

        ProxyPass / http://localhost:44909/
        ProxyPassReverse / http://localhost:44909/

        SSLEngine on
        SSLOptions +StrictRequire
        SSLProtocol TLSv1
        ServerAlias example.com
        SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

这是systemctl status tpanel(我的 ASP 守护程序)的结果:

● tpanel.service - a .NET Core 3.1 server
   Loaded: loaded (/etc/systemd/system/tpanel.service; disabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-12-13 10:16:21 CET; 4h 1min ago
 Main PID: 2765 (dotnet)
    Tasks: 16 (limit: 4915)
   CGroup: /system.slice/tpanel.service
           └─2765 /usr/bin/dotnet /var/www/TPanel/publish/TPanel.dll

Dec 13 10:16:22 vps-example dotnet[2765]: info: Microsoft.Hosting.Lifetime[0]
Dec 13 10:16:22 vps-example dotnet[2765]:       Now listening on: http://localhost:5000
Dec 13 10:16:22 vps-example dotnet[2765]: info: Microsoft.Hosting.Lifetime[0]
Dec 13 10:16:22 vps-example dotnet[2765]:       Now listening on: https://localhost:5001
Dec 13 10:16:22 vps-example dotnet[2765]: info: Microsoft.Hosting.Lifetime[0]
Dec 13 10:16:22 vps-example dotnet[2765]:       Application started. Press Ctrl+C to shut down.
Dec 13 10:16:22 vps-example dotnet[2765]: info: Microsoft.Hosting.Lifetime[0]
Dec 13 10:16:22 vps-example dotnet[2765]:       Hosting environment: Production
Dec 13 10:16:22 vps-example dotnet[2765]: info: Microsoft.Hosting.Lifetime[0]
Dec 13 10:16:22 vps-example dotnet[2765]:       Content root path: /var/www/TPanel/publish

launchSettings.json:

{
  "iisSettings": {
    "windowsAuthentication": false, 
    "anonymousAuthentication": true, 
    "iisExpress": {
      "applicationUrl": "http://localhost:50015",
      "sslPort": 44313
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "TPanel": {
      "commandName": "TPanel",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:33138"
    }
  }
}

但就像我说的,当我去的时候,example.com/panel我看到了 503 错误。我网站的其他部分运行良好。

其他信息:

  • 我有另一个使用 5001 端口的不相关应用程序正在运行,但我用其他东西替换了它,所以它应该不是问题
  • 我是否将应用程序的端口设置为33138or似乎并不重要5001,它不会改变任何东西
ubuntu apache-http-server
  • 1 1 个回答
  • 4954 Views

1 个回答

  • Voted
  1. Best Answer
    Daniel B
    2019-12-14T05:48:44+08:002019-12-14T05:48:44+08:00

    launchSettings.json是一个 VS Code 的东西。它在这里没有任何作用。

    您的应用程序在端口 5000 (HTTP) 和 5001 (HTTPS) 中运行,这是我们可以在日志中看到的不可否认的事实:

    Dec 13 10:16:22 vps-example dotnet[2765]: info: Microsoft.Hosting.Lifetime[0]
    Dec 13 10:16:22 vps-example dotnet[2765]:       Now listening on: http://localhost:5000
    Dec 13 10:16:22 vps-example dotnet[2765]: info: Microsoft.Hosting.Lifetime[0]
    Dec 13 10:16:22 vps-example dotnet[2765]:       Now listening on: https://localhost:5001
    

    Apache 配置为连接到端口 33138 上的应用程序:

        ProxyPass /panel https://localhost:33138/
        ProxyPassReverse /panel https://localhost:33138/
    

    应用程序不在该端口上侦听,因此 503 - 由 Apache 发送,而不是 ASP.NET Core。

    修复应用程序的侦听端口。例如,在appsettings.json或通过ASPNETCORE_URLS。更多信息可在此处获得。

    顺便说一句,您在ProxyPass. 这可能会导致其他问题。

    • 3

相关问题

  • 无法打开 Windows 10 和在 Hyper-v 上创建的本地托管的 Ubuntu VM 之间的端口

  • Docker 容器 ssh 错误:ssh_exchange_identification: Connection closed by remote host

  • apache2 可以在没有 conf 文件的情况下工作吗?

  • vmwared 共享文件夹不工作

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    Windows 10 服务称为 AarSvc_70f961。它是什么,我该如何禁用它?

    • 2 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Marko Smith

    ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1056)

    • 4 个回答
  • Marko Smith

    我如何知道 Windows 安装在哪个驱动器上?

    • 6 个回答
  • Martin Hope
    Albin 支持结束后如何激活 WindowsXP? 2019-11-18 03:50:17 +0800 CST
  • Martin Hope
    fixer1234 “HTTPS Everywhere”仍然相关吗? 2019-10-27 18:06:25 +0800 CST
  • Martin Hope
    Kagaratsch Windows 10 删除大量小文件的速度非常慢。有什么办法可以加快速度吗? 2019-09-23 06:05:43 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    Inter Sys Ctrl+C 和 Ctrl+V 是如何工作的? 2019-05-15 02:51:21 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve