Deploy ASP.Net Core with Plesk for Linux - linux

Following is my server environment
Server : VPS
Host : AWS EC2
OS : CentOS Linux 8.3.2011
Plesk : Plesk Obsidian 18.0.34
.Net Version : .Net Core 3.0 (Installed manually from linux CLI)
What I am look for
I am trying to deploy ASP.Net Core 3.0 api project to CentOS 8 server. Is there a way to use plesk to deploy this? May be by providing additional settings under "Apache & nginx Settings" (or any other way)?
Edit
Tried following this article - Error using ASP.NET Core in Ubuntu with Plesk
Have turned off - Reverse Proxy Server (nginx) from plesk
Added following configuration to "Additional Apache directive" under Apache & nginx Settings
.
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
SSLProxyEngine On
SSLProxyVerify none
ProxyPreserveHost On
ProxyPass / https://127.0.0.1:5001/
ProxyPassReverse / https://127.0.0.1:5001/
But getting different error.
AH00898: Error during SSL Handshake with remote server returned by /
Any help would be highly appreciated.
Many Thanks & Regards

Finally after some detailed debugging and understanding how the flow works between Plesk, Apache, NginX and ASP.Net Core, managed to get it working. Added following configuration to "Additional Apache directive" under Apache & nginx Setting.
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
Protocols h2 http/1.1
SSLEngine on
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder off
SSLCompression off
SSLSessionTickets on
SSLUseStapling off
SSLProxyEngine On
SSLProxyVerify none
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
Key thing to notice is that Proxy is redirecting to http and not https. But that is just internal in AWS server and user end is already protected by SSL configured through Apache.

Related

Apache reverse proxy not loading resources

I've configured proxy reverse with apache 2.4 on a server (ip for example 192.168.1.10) as follows:
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost Off
ProxyPass "/foo/" "http://172.20.0.3/"
ProxyPassReverse "/foo/" "http://172.20.0.3/"
mod_proxy_html is loaded.
Where 172.20.0.3 is a docker container, hosted by the server.
When I browse to 192.168.1.10/foo/ I see on the url bar 192.168.1.10/index.php (index.php is the page I actually would like to browse), but the resources required to load index.php are not found. So I get 404 page not found.
Setting / instead of /foo works, but I need to configure other proxy on the same server too.
This Q/A does not provide solution for my case: Apache ProxyPass not loading Resources
What I'm missing? Thank you

Apache 2.4 - Simple reverse proxy - not working for multiple entries

I referred the below link and configured the proxy.
https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html
When I configure a proxy for a single application as below in Apache 2.4 in the httpd.conf file, the proxy configuration is working fine. I am able to access my application through the proxy server URL.
ProxyPass / http://host1:8888/
ProxyPassReverse / http://host1:8888/
However If I try configure for two application like below, I am not able to access any of the application.
ProxyPass /nifi http://host1:8888/
ProxyPassReverse /nifi http://host1:8888/
ProxyPass /kibana http://host2:5601/
ProxyPassReverse /kibana http://host2:5601/
Not knowing how you try to reach the application makes it difficult to guess what's might be wrong.
I suggest you to change the proxies config as following:
ProxyPass /nifi/ http://host1:8888/
ProxyPassReverse /nifi/ http://host1:8888/
ProxyPass /kibana/ http://host2:5601/
ProxyPassReverse /kibana/ http://host2:5601/
then try to reach the endpoint pointing your browser to http://youdomain/nifi/ and http://youdomain/kibana/ and check the logs for errors.

How to deploy NodeJS Rest API in Ubuntu LTS 18 in apache2

I am new to NodeJS and I have a simple website that sends the contact-us information from ReactJS to NodeJS via Axios.
It is working on my local machine and I am trying to deploy it in my AWS EC2 Ubuntu LTS 18.
I have installed the PM2 already and I am stuck on what should I do next, how can I deploy my NodeJS in Ubuntu with Apache2 installed and make it run on my server even if I close my terminal. Also, what would be the API URL endpoint?
I hope someone could help me with this basic nodejs deployment in Ubuntu.
You have 2 problems:
to move the code to the server - you can use shipit.js (https://github.com/shipitjs/shipit) in order to do this. Take a look at this screencast about shipit.js and forever https://youtu.be/8PpBySjkWEM, forever is something like pm2.
to redirect traffic from Apache to your app. It is called reverse proxy. Conf file for that would be:
<VirtualHost *:80>
DocumentRoot **where-your-app-public-files-are**
ServerName **domain_name**
ProxyRequests off
ProxyPreserveHost on
ProxyPass / http://127.0.0.1:**your-node-port**/
ProxyPassReverse / http://127.0.0.1:**your-node-port**/
</VirtualHost>
Change **variables** to your data.
So it could be:
<VirtualHost *:80>
DocumentRoot /var/www/your-app
ServerName your-domain-name.com
ProxyRequests off
ProxyPreserveHost on
ProxyPass / http://127.0.0.1:4040/
ProxyPassReverse / http://127.0.0.1:4040/
</VirtualHost>

access tomcat application via the domain name

I have a virtual cloud server on aws where there is tomcat 7 running on port 8080 eg. a.x.y.z:8080 (where a.x.y.z is the public ip). I have an application deployed on the tomcat on context path "hello" so that I can access it like a.x.y.z:8080/hello .
Now I have bought a domain name example.com and have translated it to the public ip a.x.y.z so that now I can access my application via the url example.com:8080/hello but actually what I want is that on hitting example.com I would be able to access my application. How to achieve it ?
You can access your tomcat application with your domain name using mod_proxy modules, please login your server and update your httpd configuration with following code.
ProxyPreserveHost On
ProxyPass / http://0.0.0.0:8080/
ProxyPassReverse / http://0.0.0.0:8080/
NOTE : Update your correct server IP instead of 0.0.0.0 in above code.
Ok, I solved the issue :
After installing apache2, in the /etc/apache2/apache2.conf file
I appended :
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.example.com
ServerAlias example.com
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
Saved the file and restarted the apache2 server.
With this, whenever I hit example.com, I will get the homepage of tomcat (localhost:8080). then i opened the tomcat manager (example.com/manager/html) and stopped & undeployed the application at root (/) path. (As a result of this, whenever you hit example.com, you will no longer see tomcat homepage, instead a blank page)
Now I deployed my application as root in tomcat. If you are using maven you can do so like here .
As a result of this my application was available in example.com .
(If you don't deploy your application as root, you have to access it using example.com/myapp)
Now, whenever I hit example.com myapp will be accessed.

Apache 2.2.3 reverse proxy issue

I have to setup a website https://xyz.abc.co.in using self-signed certificate. I have apache 2.2.3 on Redhat Linux. But the home page of that website should come from a remote server application i.e http://10.x1.x2.x3:7080/app working on glassfish.
When i write http://10.x1.x2.x3:7080/app in browser it opens http://10.x1.x2.x3:7080/app_web/login.html
Now on my Apache 2.2.3 i have following entry in my httpd.conf to call http://10.x1.x2.x3:7080/app through remote proxy :-
< VirtualHost * :443 >
ServerName xyz.abc.co.in
SSLEngine On
SSLProxyEngine On
ProxyRequests Off
ProxyPreserveHost On
SSLCertificateFile /etc/*/redhat.crt
SSLCertificateKeyFile /etc/*/redhat1.key
SetOutputFilter proxy-html
ProxyPass / http://10.x1.x2.x3:7080/app/
ProxyPassReverse / http://10.x1.x2.x3:7080/app/
< /VirtualHost>
Now when i use https://xyz.abc.co.in in browser it gives error "NO DATA RECIEVED".
I have loaded module proxy_html also.
When i remove directive "SetOutputFilter proxy-html" then it gives error that :-
/app_web/login.html is not found on port 80 of apache 2.2.3 ( although it is hosted on glassfish on remote server). When I use "ProxyHTMLInterp On" then also there are the same errors recieved in browser.
....When i use "ProxyHTMLEnable On" it says invalid command while starting apache.
Please suggest.

Resources