Hi All,
I Think I could run ASP.Net Core 8.0 on ubuntu (20.04) and Apache via aaPanel.
I am going to share all the details to show you the way. But I will need further more asistance about some details to go beyond.
All answers and attentions are appreciated.
By the way, following link about the installation .Net core on Ubuntu via aaPanel can help you to understand basics of the proccess:
https://relaxedcoder.com/blog/tutorial-easy-deploy-of-net-core-to-linux-on-linode/#deploy-net-core-web-api-on-aapanel
However it only shows the Nginx configuration, not Apache.
Main difference between the configuration of mine and the explained config on the link is only that I prefer LAMP package while I was configuring the aaPanel. So I use Apache instead of Nginx.
So here is what I did:
First of all, I've installed the .NET Core SDK and runtime as suggested.
I created a blank ASP.Net Core template and checked HTTPS settings while creating.
Published all the files and deleted the appsettings.development.json file as it is not neccessary in production environment. (Only appsettings.json file should remain in the publish folder.)
I've modified the appsettings.json file to configure Kestrel ports as follows:
`{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://127.0.0.1:5080",
"Protocols": "Http1"
},
"Https": {
"Url": "https://127.0.0.1:5443",
"Protocols": "Http1",
"Certificate": {
"Path": "/Your_certificate_path_written_in_config_file.pem",
"KeyPath": "/Your_key_path_written_in_config_file.pem"
}
}
}
}
}`
Uploaded all files to the server.
To set the reverse proxy, I navigated to aaPanel domain settings and found the reverse proxy settings and I set the target URL as http://127.0.0.1:5080/ and saved the config.
To add some more lines to reverse proxy config, clicked the config section of the reverse proxy settings and manually add those lines:
#PROXY-START/
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPreserveHost On
SSLProxyEngine on
SSLProtocol all
ProxyPass / http://127.0.0.1:5080/
ProxyPassReverse / http://127.0.0.1:5080/
RequestHeader set Host $host
RequestHeader set X-Real-IP %{REMOTE_ADDR}s
RequestHeader set X-Forwarded-For %{HTTP:X-Forwarded-For}s
RequestHeader set X-Forwarded-Proto %{REQUEST_SCHEME}s
</IfModule>
#PROXY-END/
And started the service from terminal via dotnet command in website folder:
dotnet WebApplication_test.dll
So kestrel displayed that it is listening on ports 5080, 5443. as expected.
Navigated to the website on browser and .Net Core application started succesfully.
So far so good.
However If I tried to upload any other complex template for ASP.Net core, It did not work and it redirected me to my own local-127.0.0.1:5443.
So I tried different reverse proxy settings but similarly redirected to https://$host:5443/, Or mysub.mydomain.com:5443. It is funny.
- I strongly beleive that a proper reverse proxy config may solve this issue but I could not find the correct way of to do it.
- Also thinking that maybe .htaccess file should be customized to use some .Net core templates with Open API supports etc.
Can anybody comment and help on those?
Thanks for your time and attentions in advance.