Serving Node.JS app on a existing server running page on port 80 - node.js

I have a server at www.example.com running a PHP-made webpage served by Apache, this page is listening to port 80.
Now I want to serve my Node.JS on the domain www.example2.com. Both pages should be on the same server, the Node.JS app should be running on port 3000. How do I achieve this?
From other answers and blog posts (like this one: http://garr.me/blog/running-node-js-and-apache-together-using-mod_proxy/) I have learnt that I can create a ReverseProxy to redirect www.example.com/app to my app, however this is not the intended behavior. What I want is this new domain www.example2.com to go the server's ip address at port 3000.
Side question: This question might sound stupid but, can't I redirect the whole domain to the server's IP address at port 3000 from the domain name configuration at GoDaddy/Route53???
Thanks.

Yes to your side question. i think thats the best approach. Have your domain configuation on go daddy go to the ip address and 3000 port.

Related

How to link node+express server to domain

I have a domain name pointing to my vps IP. But when I run my express server I have to set a port, usually I use 3000, so the only way to get in my website is specifying the port: www.mysite.com:3000.
How can I make my app run in my domain without adding any port? My first guess was setting also the port in my domain name provider (111.11.11.11:3000) but Godaddy doesn't let me to add the port.
How can I make it work?
Newbie question, I know, but i'm a first timer and haven't found any answer to this.
The correct way is to change the port its hosted on. The default port for http traffic is 80, the one for https is 443. I assume you are on linux, if so you need to give some special permissions as ports below 1024 are privileged ports.
TLDR: if running http, change your express config to 80, if https 443
If using express, you need to change express port from 3000 to 80 if you plan using HTTP or 443 if you plan using HTTPS.
This is assuming your VPS does not already use port 80 or 443 while running an HTTP server like apache or nginx.
If you are in this case you will need to set up a reverse proxy.
I went for Nginx solution, I could make the port forward really easy following this guide:
https://eladnava.com/binding-nodejs-port-80-using-nginx/
For those who face this problem, solution is much more easier than it could look at beginning.

Namecheap domain name for DigitalOcean

Beginner question here. I tried plenty of tutorials but I cannot seem to get the domain name up.
Basically, I deployed my node app on DigitalOcean and the link works (I use the port 5000 jic). These are the steps I took from there:
Set up a domain on DigitalOcean.
Copied the 3 DNS links (ns3.digitalocean.com) to namecheap on custom DNS.
Create a new record on DigitalOcean with the IP of my project (without port as thats not accepted).
I can now access the website using the domain name but I need to put the port number as well, ie. mylink.com:5000
How do I avoid that or can someone explain me the right steps to link my namecheap domain with my digitalocean node app? This is my first time doing this.
Basically you cannot, you should either use port 80 for HTTP, or port 443 for HTTPS so the URL won't need a port (it defaults to them automatically) or you will have to use reverse-proxy (e.g. nginx) if you have to keep your port 5000.

AWS redirect URL with AngularJS running in Node.js server

I´m trying to config a website hosted in AWS EC2 instance. But Im a bit mixed!!
I have an AngularJS application running in a Node.js server listening on port 1234. This site is deployed correctly, so when I get the url in a browser ec2-instance-public-dns:1234/app/index.html I see my site perfectly.
In the other hand, I registered a domain name in GoDaddy. I set up a Route 53 and the DNS names in GoDaddy.
I see, I also have a load balancer listening in port 80, that is redirecting to port 1234.
What I need is to link my domain with my site in the path ec2-instance-public-dns:1234/app/index.html
All this stuff is not working. How can I achieve this?
Is there is reason why you don't have Node listen to 80 or 8080 ?
Does the DNS redirection work ? -> Can you access your site with www.yourdomainname.com:1234 ?
-> If no, then check your dns config, you should not have to deal with port routing at that level.
Are you using Linux as your EC2 instance ? If yes, reroute port 80 toward port 1234 as explained here (http://www.cyberciti.biz/faq/linux-port-redirection-with-iptables/).
That how I do it, hope that helps.

How to specify the port serving CherryPy app in the DNS entry?

I receive a "Port 80 not free" message when I try to serve my CherryPy app on port 80. Most examples I see show folks using other ports. If I use another port how do I specify the port serving my CherryPy app in the DNS entry?
We're using Easy DNS and from what I can tell there is no way to specify the port in the DNS entry. Is this standard or a restriction with our provider?
Want to achieve something like this:
XXX.XXX.XXX.XXX - www.domain.com:9595
Thanks in Advance!
Andrew
To publish the TCP port number for your web site in DNS, you can create an SRV record, but there is no point in doing that since there are probably exactly zero web browsers in existence that actually query SRV records to find out which port to connect to.
So since SRV doesn't work, the short answer is to your question is, you can't. If your web server runs on a different port than 80 (for HTTP) or 443 (for HTTPS) then it is only possible to access it by specifying the port number directly in the URL, like http://www.domain.com:9595/.
If you really prefer to have your web site appear to be on port 80 (for HTTP) or 443 (for HTTPS) and there is already another web server listening on that port, then you can see if you can configure the other web server to proxy requests to your web server. For example, if the other web server runs Apache, then:
<Location /foo>
ProxyPass http://localhost:9595/
ProxyPassReverse http://localhost:9595/
</Location>

How do IP addresses work on a VPS? Routing a domain name to Node.JS

This is an absolute newb question. But I'm buying my first VPS for the reason that I want to install and start creating applications in Node.JS.
I can't visualise in my mind how the server works and where all of the applications such as Apache, Node.JS and PHP sit. I'm so used to a GUI.
I want www.mydomain.com to point to node.JS on my server, let's say Node is listening to port 8080. Now I know that HTTP defaults to port 80 of the IP address, so I can't use that. How do I set the domain up to resolve at www.mydomain.com:8080 - I read this wasn't possible...
My brain is melting.
Thanks :)
You just point the domain to your ip address as you normally do. The issue you will have it that HTTP default to port 80, so either you manually add the port at the end of the host to get to the page or you setup Apache to proxy specific urls to 8080, which gets some of your Node stuff appearing to work under 80.
If you aren't using Apache for anything you can also have your Node app bind to port 80. You will probably need to setup authbind or something to give your node app permission to bind to port < 1024.

Resources