Reverse proxy using nginx on bluehost vps does not works with subdomains - node.js

I have bluehost VPS hosting on which I am hosting a node js app. I have configured my vps server and installed nginx on it. Now I am using the reverse proxy to redirect the domain.com to localhost:3000 which is running node js app. Now I have a second node js app that I want to run on sub.domain.com which is running on localhost:3001. I created the subdomain on bluehost then used the same reverse proxy config for sub.domain.com but it is not working.
and
?

I don't know why but adding
"proxy_redirect http://localhost:3001 http://sub.domain.com;"
in configuration file of subdomain fixed my problem :)
Solution Configuration

Related

add subdomain for node.js application in DirectAdmin

On my VPS I host several laravel applications.
Subdomains are added using DirectAdmin and VirtualHost settings are done using the DirectAdmin Httpd.conf customization, like:
|*if SUB="cluego"|
|?DOCROOT=/home/admin/domains/netwerkspel.nl/public_html/cluego/public|
|*endif|
|*if SUB="ijsbrekerz"|
|?DOCROOT=/home/admin/domains/netwerkspel.nl/public_html/ijsbrekerz/public|
|*endif|
Now I want to add the subdomain for qruzzle:
|*if SUB="qruzzle"|
|?DOCROOT=/home/admin/domains/netwerkspel.nl/public_html/qruzzle|
|*endif|
But qruzzle is a node.js application, and in the qruzzle directory a server.js is running on port 3000.
Can anyone tell me how I can configure this in the easiest way? Do I need to set up a reverse proxy? Is that possible using DirectAdmin?

Reverse proxy to serve local reactjs application on a static url with virtualmin

I've got a locally running reactJS app that I'd like to run as a subdomain on a domain hosted on virtualmin, so that the app can be hosted locally but seen publicly.
ngrok.io allows you to serve a locally running reactjs application (or a lot of other things) through a publicly visible subdomain.
(My intention is to answer my own question, because when I searched, I ran into a lot of dead ends. I tried to use as many keywords as I used while searching out the answer.)
On Virtualmin, click on 'Create Virtual Server'
For the domain name, use "subdomain.x.com"
Enabled Features: Setup DNS Zone (if necessary), apache website enabled, and apache ssl website enabled.
Click on Server Configuration -> Edit Proxy Website
Set "Proxy enabled?" to "Yes". Proxy to url: http://localhost:12809/
Run your reactjs app on your localhost. We're assuming it is running on port 8301.
On your localhost, establish an ssh tunnel to your server; do:
ssh -N -T -R 12809:localhost:8301 user#x.com
reload "subdomain.x.com" and your locally running reactjs app will be seen publicly there.
If you need websockets enabled, make sure to add this to your apache configuration file at Services->Configure Website->Edit Directives.
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* ws://localhost:12809%{REQUEST_URI} [P]
in the RewriteEngine On section
edit: this was an unnecessary step when i originally wrote this, but i'm leaving it here to show how you can route through yet another server if you want/need:
) Download 'caddy' to your virtualmin user home directory: https://caddyserver.com/download
) Then run a reverse proxy on caddy from the port that will connect to your localhost (9000, in this case) to the port that is served from subdomain.x.com:
`./caddy reverse-proxy --from :12809 --to 127.0.0.1:9000`
) in this case you'd run your ssh on your localhost like 9000:localhost:8301

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

Setup domain for VueJS server on network

I have a project that use a NodeJs server for back-end and VueJs for front-end.
I run the front-end server using this:
npm run serve
Now, I have a domain
duduman.ro
And I want to set the domain for my app that runs on localhost:8080
I tried using apache, but i didn't succeed.(setting virtualhost)
<VirtualHost *:8080>
ServerName duduman.ro
</VirtualHost>
I also tried to set a subdomain: app.duduman.ro for 8080 port, but calling "app.duduman.ro" return "Object not found" and calling "app.duduman.ro:8080" return "Invalid Host header".
PS: The port is forwarded correctly because external ip using port 8080 works just fine.
Check out Heroku node.js app, it should solve your issues.
https://www.heroku.com/nodejs
For me is the easiest way to deploy.

Redirect a url to a local server

Is there any way to redirect a url to a local server?
Like http://example.com/1.js to http://localhost/1.js, without changing hosts file, using node js.
To configure apache on windows, refer this link proxy on windows
To configure apache on UBUNTU, refer this links
Apache2 reverse proxies
Apache proxy on ubuntu
In below code,
if i visit localhost/http-bind. it will hit localhost:5280/http-bind/
ProxyPass /http-bind http://localhost:5280/http-bind/

Resources