.Net Core not handling requests when defined in subdomain folder - linux

I have a Linux Centos v7.9 with Apache installed. I published my web project to the server. For the backend I set it on port 90 and created a configuration file for apache with proxy server (to redirect to another port 31031, where .net 5 is listening and handling the requests. This works fine when I request my server ip with port 90. But when I wanted to set the backend as subdomain like api.domain.com and modified the configuration file, .net 5 is not handling the request anymore. When I request api.domain.com I see folder structure. What did I miss?
Here is the .conf file:
Service file:
Subdomain from cpanel:
Thanks.

Related

Windows IIS with Next js App Internal Server Error 500

I'm trying to deploy my Next.js app on VPS Windows 10 with Plesk panel and Windows IIS.
The problem is I created domain name from Plesk panel and it works fine. And I have localhost for Next.js app on port 3000 I'm trying to connect to localhost:3000 with the domain using IIS rewrite Reverse Proxy
IIS rewrite Reverse Proxy:
But it gives me internal server error 500:
I tried this on React.js and Next.js, and Next.js with Express custom server. Still the same error.
But when I try with Vue.js or Node.js express server, it works just fine.
And when I open port like this domain.com:3000 it also works with react and next.
What can I do?
After searching for a while I found the solution problem is the iis can't use Url Rewrite proxy if you using gzip and Next.js provides gzip compression to compress rendered content and static files so to fix this error you need to turn gzip off or enable gzip on iis.
If you want to disable the gzip on next js follow this
https://nextjs.org/docs/api-reference/next.config.js/compression
If you want to using gzip enable gzip on iis this wll help you to using gzip
https://techcommunity.microsoft.com/t5/iis-support-blog/iis-acting-as-reverse-proxy-where-the-problems-start/ba-p/846259
Here I found the solution:
https://learn.microsoft.com/en-us/archive/blogs/friis/iis-with-url-rewrite-as-a-reverse-proxy-part-2-dealing-with-500-52-status-codes

Phusion Passenger + Apache + Node.js app runs on http but not https. 404 Error

I have a Phusion Passenger Node.js application configured with cPanel that ran perfectly on my primary domain. I created a new application that uses the same path but switched the domain to another domain on my account. On the old domain: ghv.xie.mybluehost.me, the application worked on both http and https.
http://ghv.xie.mybluehost.me/portal
https://ghv.xie.mybluehost.me/portal
On the new domain: csmithcpa.com, the app only works on http. https returns a 404 error.
http://csmithcpa.com/portal
https://csmithcpa.com/portal
I am not sure how to debug this or why it would return a 404 at all on https but completely work on http. Any help would be fantastic.
EDIT: I will keep adding useful information for debugging as more people ask questions about it.
cPanel/WHM access
Apache server
Phusion Passenger application manager
Node.js web application
-portal
--app.js
--node_modules
-public_html
--ghv.xie.mybluehost.me site files
--csmithcpa
---csmithcpa.com site files

Spring boot .jar to digital ocean droplet (Linux Ubuntu) :Web server failed to start. Port 80 was already in use

I have an Digitalocean Droplet (virtual private server) that has Ubuntu 18.04 running on it. I installed Apache Web Server and have my website running on it . It's open to traffic on HTTP port 80. My virtual host is setup at /var/www/MyDomainNameHere/public_html/ and I do have a custom domain name pointing to the IP.
I am trying to deploy/run a executable .jar that contains a Spring boot API. It has some basic GET/POST/DELETE HTTP requests. When I run the jar by
java -jar rest-service.jar
I get this error message
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 80 was already in use.
Does this mean the Apache Web Server that is open to Traffic on port 80 on this Digital ocean droplet won't let me run the API jar on the same server (The JAR loads up an Apache Tomcat embedded server, I set it to port 80 based on research)? Do I need to buy another droplet? Or can I maybe change the port number for the spring boot jar to something other than port 80? It's an API, so I need to be able to hit the end points
Yes, Apache Web Server using the port and you change your spring application 80 to any other port and use the reverse proxy in Apache Web server. here is the link to configure the reverse proxy
Apache as a Reverse Proxy with mod_proxy
So I will answer my own question. I googled and searched stackoverflow but most people were using the reverse proxy to direct traffic to their standalone embedded Tomcat server (most of time a Spring Boot app) which wasn't applicable to my situation.
However, I already had a static html website at alpizano.me hosted on Digital Ocean that I wanted to use as my Front-end, and only forward certain HTTP requests to my Spring Boot app, which was a REST API essentially.
So after installing Java and PostgreSQL on my DigitalOcean droplet, I SCP'd my JAR file (running ./mvnw clean package -Dmaven.test.skip=true to create it) to my server to a directory like, /var/myapp.
Then after researching for a few days and trying multiple things, I was able to figure out the combination that would allow me to view my website when navigating to alpizano.me, but still allow me to hit my API endpoints that were running on my server as-well, after I ran my jar via java -jar myapp.jar
So I basically had to set up my .conf file in the /etc/apache2/sites-available dir (I only used 1 virtual host for this project) as:
<VirtualHost *:80>
ServerName yourservername.com
DocumentRoot /var/www/yourservername.com/public_html
ProxyPreserveHost On
ProxyPass /api http://127.0.0.1:8080/
ProxyPassReverse /api http://127.0.0.1:8080/
</VirtualHost>
Notice the /api route for the routing that goes to the embedded Tomcat at port 8080 (you can't use port 80 or it will conflict with Apache Server already listening on port 80), else if it's just / , then it will not allow traffic to base website anymore (alpizano.me), which isn't what I wanted.
This wouldn't be needed if you just had a standalone app that you wanted to route traffic, then you could just use / as your route obviously. I saw other posts talking about forwarding the headers but that didn't seem to make a difference for me and I believe ProxyPreserveHost On takes care of that anyway
Good luck.
References:
https://www.digitalocean.com/community/tutorials/how-to-use-apache-as-a-reverse-proxy-with-mod_proxy-on-ubuntu-16-04

Running both Node.js and Apache on the same domain and "URL"

Is it possible to run Both node and Apache on the same domain without adding the port in the URL ?
and serve both on the same page, i already have node running on port 8443 and Apache on port 433 and they both work fine but i need to specify in the link the port "8443" to access node which is not what i want,
i want to serve both on the same URL if possible without adding the port to the URL.
You can use Apache reverse proxy
Add this configuration to your apache conf.
ProxyPass "/nodeapp" "http:/localhost:8443"
You can access node application by http://www.example.com/nodeapp
A reverse proxy is a type of proxy server that retrieves resources on behalf of a client from server. These resources are then returned to the client as if they originated from the web server itself.
You can set an nginx proxy before them and separate routes to apache or node.
https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/

hosting nodejs code in Apache Tomcat server

Is it possible to host a node.js application on Apache tomcat server and then expose an https url from it? I would like to access the https url from other machines.

Resources