I've been following a blog on how to install ASP.NET Core In .NET 5 App On Ubuntu 20.04. When I visit the link api.example.com, it showing default apache page. It should be showing me the ASP.NET Core app.
All the application files are stored in /var/www/api/ and ownership has been given to www-data
VirtualHost api.conf
In the VirtualHost I have the following configurations and the conf is enabled.
<VirtualHost *:*>
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
</VirtualHost>
<VirtualHost api.example.com:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ServerName api.example.com
ServerAlias api.example.com
ErrorLog ${APACHE_LOG_DIR}api-error.log
CustomLog ${APACHE_LOG_DIR}api-access.log common
</VirtualHost>
Add Service
The following service configuration has been added and service has been enabled.
[Unit]
Description=Api
[Service]
WorkingDirectory=/var/www/api/
ExecStart=/usr/bin/dotnet /var/www/api/Api.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=api
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
When I run sudo systemctl status api.service I get the following
ubuntu@sandbox:~$ sudo systemctl status api.service
● api.service - Api
Loaded: loaded (/etc/systemd/system/api.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2021-07-04 12:28:54 UTC; 12h ago
Main PID: 21133 (dotnet)
Tasks: 13 (limit: 1116)
Memory: 33.3M
CGroup: /system.slice/api.service
└─21133 /usr/bin/dotnet /var/www/api/Api.dll
Jul 04 12:28:55 sandbox api[21133]: warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
Jul 04 12:28:55 sandbox api[21133]: No XML encryptor configured. Key {cb00126e-6ce8-41cc-9568-800ff705be3a} may be persisted to storage in unencrypted form.
Jul 04 12:28:55 sandbox api[21133]: info: Microsoft.Hosting.Lifetime[0]
Jul 04 12:28:55 sandbox api[21133]: Now listening on: http://localhost:5000
Jul 04 12:28:55 sandbox api[21133]: info: Microsoft.Hosting.Lifetime[0]
Jul 04 12:28:55 sandbox api[21133]: Application started. Press Ctrl+C to shut down.
Jul 04 12:28:55 sandbox api[21133]: info: Microsoft.Hosting.Lifetime[0]
Jul 04 12:28:55 sandbox api[21133]: Hosting environment: Production
Jul 04 12:28:55 sandbox api[21133]: info: Microsoft.Hosting.Lifetime[0]
Jul 04 12:28:55 sandbox api[21133]: Content root path: /var/www/api