我有一个库存的、几乎未修改的 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 端口的不相关应用程序正在运行,但我用其他东西替换了它,所以它应该不是问题
- 我是否将应用程序的端口设置为
33138
or似乎并不重要5001
,它不会改变任何东西