In a Ubuntu 18.04 server I have Apache (currently running several PHP sites whit no problem). Now I need to host a .NET app (v 3.1).
Followed this tutorial https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1
The app is working if I'm not wrong
# 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
My Apache virtualhost is defined this way:
<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>
The .service content is:
[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
When I go to XXXX-api.AAAA.com.ar it redirects me to XXXX-api.AAAA.com.ar:5001 and shows a ERR_CONNECTION_TIMED_OUT error
Error log shows this:
[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
I'm a bit lost here (I'm not even a .NET dev, my skills are in PHP)
<VirtualHost *:80> ProxyPreserveHost On 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>
When I open it in the browser it redirects (307) me to testnet.XXXXX.com.ar:5001 and shows ERR_CONNECTION_TIMED_OUT – OscillatorListen 5000
now I get a different error:ERR_CONNECTION_REFUSED
and the headers showsLocation: https://testnet.XXXXX.com.ar:5001/ Server: Kestrel
– Oscillator