0

I am hosting a net6 web app on Ubuntu (Port 80 is opened). My service file:

[Unit]
Description= companydir .NET Core Web Application

[Service]
WorkingDirectory=/var/www/companydir
ExecStart=/home/ubuntu/.dotnet/dotnet /var/www/companydir/webapp.dll
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-webapp
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

When I run the following commands, I dont see errors.

sudo journalctl -fu webapp

sudo systemctl status webapp

I see mysql queries and that my service is active

Loaded: loaded (/etc/systemd/system/webapp.service; enabled; vendor preset: enabled) 

Active: active (running) since Wed 2022-02-09 20:52:13 EST; 24h ago

But when I go to the URL online, It says the site cant be reached. I don't know what happened.

Update Config file:

<VirtualHost *:80>
   ServerName company.com
   ServerAdmin admin.com
   DocumentRoot /var/www/company.com
   ProxyPreserveHost On  
   ProxyPass / http://localhost:5000/ 
   ProxyPassReverse / http://localhost:5000/  
   RewriteEngine on  
   RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]  
   RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]  
   RewriteRule /(.*) ws://127.0.0.1:5000/$1 [P]  
   ErrorLog ${APACHE_LOG_DIR}/error-company.com.log  
   CustomLog ${APACHE_LOG_DIR}/access-company.com.log combined  
</VirtualHost>
DavidJS
  • 417
  • 2
  • 5
  • 16
  • Did you configure the [reverse proxy in Apache](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-6.0)? – Oleg Naumov Feb 11 '22 at 15:49
  • I updated my question with the config file..Is that what you mean? – DavidJS Feb 11 '22 at 18:27
  • Yes. At a first glance, it appears to be fine. Are you getting `DNS_PROBE_FINISHED_NXDOMAIN` error in Chrome? Try this: 1. Run `webapp.dll` from the terminal to make sure it actually starts up and then see if you can access it online. 2. I would double-check if the domain is actually pointed to the correct IP address. – Oleg Naumov Feb 11 '22 at 19:47
  • No, Chrome shows ERR_CONNECTION_REFUSED. I tried dotnet webapp.dll and I got Unhandled exception. System.IO.IOException: Failed to bind to address http://127.0.0.1:5000: address already in use. My config file was bound to that address. – DavidJS Feb 12 '22 at 18:40
  • Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp6 0 0 ::1:5000 :::* LISTEN - tcp6 0 0 :::80 :::* LISTEN - – DavidJS Feb 12 '22 at 18:47
  • Have you seen this [answer](https://stackoverflow.com/a/56209024/7264799)? There is a chance that your app is enforcing HTTPS that's not configured on your server. Try removing `app.UseHttpsRedirection();` and see if the app loads. – Oleg Naumov Feb 13 '22 at 23:00
  • @OlegNaumov - I have the line for Development only, but I took it out just in case. No resolution. – DavidJS Feb 14 '22 at 03:48
  • I know it sounds stupid but did you restart the Apache server after you created the configuration file? Other than it's hard to say what else can cause it without really digging into your project. I would recommend taking it back to basics and setting up a fresh new server with a simple [Hello World](https://docs.microsoft.com/en-us/visualstudio/ide/quickstart-aspnet-core?view=vs-2022) application, just to make sure that Apache is configured correctly. If the `hello world` app is online, then switch it to your `webapp`. Set up `systemd` service after verifying that everything is working. – Oleg Naumov Feb 14 '22 at 14:14
  • I have restarted apache many times since. Ok, Well then I may have to do that – DavidJS Feb 14 '22 at 18:24

0 Answers0