I installed NET Core SDK on Ubuntu 18.04 following the official guide:
https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install
I created a C# Hello World project with command dotnet new razor and published with dotnet publish.
I configured a new domain in Plesk with a sub-domain.
I configured (using the official reference: https://learn.microsoft.com/it-it/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-2.2) in Plesk, under Apache & nginx Settings, with the following example:
Additional directives for HTTP/HTTPS:
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ServerName sub.mydomain.com
ServerAlias *.mydomain.com
ErrorLog ${APACHE_LOG_DIR}helloapp-error.log
CustomLog ${APACHE_LOG_DIR}helloapp-access.log common
I moved the published project under subdomain folder and started it with command dotnet myproject.dll
I received the following output:
Hosting environment: Production
Content root path: /var/www/vhosts/mydomain.com/sub.mydomain.com
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
Opening sub.mydomain.com in browser I receive the following error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at logx.edotto.com Port 80
In subdomain log I can see only this:
Can someone give me a hint to look somewhere to resolve this error?
There's something I can check to receive further details about the error?
1 Answer 1
Fist you need temporary to disable the nginx since using plesk as platform panel, flow of data exchange is:
- end-user-request-start -> nginx -> apache [ script/code executed ] -> reverse/proxy request back to nginx -> final result to end-user.
Plesk Location from were you can temporary disable the nginx: Server Managment -> Tools&Settings -> Services -> Reverse Proxy Server (nginx ) - ( click on stop icon and wait for a while, once the service is stopped green check mark will disappear and grey circle will be present )
Now all request will be served by only apache2 , and then following official Microsoft Apache2 directives can be applied and sub-domain will be able to serve the requests that are ending into Kestrel server ( which will have proxy and reverse proxy directives to be able to communicate with apache 2 )
Also very important ! the same apache directives that you apply under sub-domain, it's mandatory and accordingly to be applied also under apache directives main domain. Once you are done with it, and testing is completed then , you can re-enable the nginx reverse proxy service , and under appropriate domain, sub-domain, under nginx settings , check-box Proxy mode - needs to be selected, in order the nginx to use the apache and within the directives
example for apache directives if sub-domain has ternary or quarter name : main domain: main-domain.com
**- ServerName: subdomain-name2.sub-domain-name1.main-domain.com
**- ServerAlias: *.main-domain.com
sub-domain: subdomain-2.sub-domain-name1.main-domain.com
**- ServerName: subdomain-name2.sub-domain-name1.main-domain.com
**- ServerAlias: *.subdomain-1.main-domain.com
Also please include in both, sud-main and main-domain, apache2 directives on top as first line:
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
And you can change if you like the errors and access activities in the logs to appear in the same log as apache2 is using ( error.log and access.log ) - this minor change will enable using plesk webplatform and mobile app to appear the logs and activities to be accessible within.
That changes can be done with small change in the following lines:
ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined
Also if you deside to use the dotnet core application as an service as it's described into Microsoft link: using systemctl , be carrefull that installation of systemctl will substitute the upstream ( service module/controler which plesk is using , at least in my Ubuntu 14.04 messed-up, potentially the kernel version and systemctl since is older, and plesk is not re-writing in the same place the symbolic links, )
- Only if your server is Ubuntu 14.04 and Plesk and you have installed the systemctl ( which was not installed by default ) execute the following to recover the symbolic link issues, ( in this use-case scenario, systemctl monitors/runs the dotnet core 2.1 application )
sed -i.orig s/systemctl/systemctl_pp/g /opt/psa/admin/sbin/pleskrc
And after this command is executed, into Plesk WebPro WebPanel, under-Home, within notification error message there are ( two links marked with here ) click - here the link that refers to: recreate all-apache2 configuration files, wait for it, and once done the Plesk Server will continue with OK state, and you'll have Plesk up and running with both nginx - as reverse-proxy towards apache and active and running dotnet core are service using systemctl.