在 Ubuntu 18.04 服务器上,我安装了 Apache (目前运行多个 PHP 网站没有问题)。
现在我需要托管一个 .NET 应用程序(v 3.1)。
按照此教程操作 https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1 如果没有错的话,应用程序正在运行。
我的Apache虚拟主机是这样定义的:
当我访问XXXX-api.AAAA.com.ar时,它会将我重定向到XXXX-api.AAAA.com.ar:5001,并显示ERR_CONNECTION_TIMED_OUT错误。
错误日志显示如下:
按照此教程操作 https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1 如果没有错的话,应用程序正在运行。
# sudo systemctl status kestrel-helloapp.service
● kestrel-helloapp.service - Example .NET Web API App
Loaded: loaded (/etc/systemd/system/kestrel-helloapp.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2020-03-10 15:27:21 UTC; 1h 33min ago
Main PID: 70301 (dotnet)
Tasks: 15 (limit: 4675)
CGroup: /system.slice/kestrel-helloapp.service
└─70301 /usr/bin/dotnet /var/www/helloapp/NetTest.dll
Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: info: Microsoft.Hosting.Lifetime[0]
Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: Now listening on: http://localhost:5000
Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: info: Microsoft.Hosting.Lifetime[0]
Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: Now listening on: https://localhost:5001
Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: info: Microsoft.Hosting.Lifetime[0]
Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: Application started. Press Ctrl+C to shut down.
Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: info: Microsoft.Hosting.Lifetime[0]
Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: Hosting environment: Production
Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: info: Microsoft.Hosting.Lifetime[0]
Mar 10 15:27:22 Clk-Dev-UbuntuApache-01 dotnet-example[70301]: Content root path: /var/www/helloapp
我的Apache虚拟主机是这样定义的:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
ServerAdmin webmaster@localhost
ServerName XXXX-api.AAAA.com.ar
ServerAlias www.XXXX-api.AAAA.com.ar
ErrorLog ${APACHE_LOG_DIR}/XXXX-api.error.log
CustomLog ${APACHE_LOG_DIR}/XXXX-api.access.log combined
</VirtualHost>
.service 内容如下:
[Unit]
Description=Example .NET Web API App
[Service]
WorkingDirectory=/var/www/helloapp
ExecStart=/usr/bin/dotnet /var/www/helloapp/NetTest.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=afiori
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
当我访问XXXX-api.AAAA.com.ar时,它会将我重定向到XXXX-api.AAAA.com.ar:5001,并显示ERR_CONNECTION_TIMED_OUT错误。
错误日志显示如下:
[Tue Mar 10 15:06:49.538374 2020] [proxy_http:error] [pid 47754] [client 152.171.888.888:60836] AH01114: HTTP: failed to make connection to backend: 127.0.0.1
[Tue Mar 10 15:08:38.802652 2020] [proxy:error] [pid 9643] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:5000 (127.0.0.1) failed
[Tue Mar 10 15:08:38.802698 2020] [proxy_http:error] [pid 9643] [client 152.171.888.888:60899] AH01114: HTTP: failed to make connection to backend: 127.0.0.1, referer: http://XXXX-api.AAAA.com.ar
我有点迷失了(我甚至不是.NET开发人员,我的技能在于PHP)
ProxyPass / http://127.0.0.1:5000/ ProxyPassReverse / http://127.0.0.1:5000/ ServerAdmin webmaster@localhost ServerName testnet.XXXXX.com.ar ServerAlias www.testnet.XXXXX.com.ar ErrorLog ${APACHE_LOG_DIR}/testnet.error.log CustomLog ${APACHE_LOG_DIR}/testnet.access.log combined
</VirtualHost>`当我在浏览器中打开它时,它会重定向(307)到https://testnet.XXXXX.com.ar:5001/并显示ERR_CONNECTION_TIMED_OUT。 - drcrowListen 5000
,现在我得到了不同的错误:ERR_CONNECTION_REFUSED
,头部显示Location: https://testnet.XXXXX.com.ar:5001/ Server: Kestrel
- drcrow