setting up a MEAN app in production - node.js

I am a frontend developer and having issues setting up my MEAN app in production server. I am confused about the role of apache ? if any.
right now I don't have a domain name, just an IP address for a CentOS 6 VPS.
I stopped apache and am using express only, I deployed the app code and ran the grunt task in production environment and the app is listening on port 3000 .. but when I visit the site at
http://104.238.103.223:3000/ I get a "page not available" error
I am confused at how to specify a "DocumentRoot" without apache ? how do I tell DNS where to find my app ? I may be looking at the problem wrong since I am not well aware of the backend side of things.

You should reverse proxy to port 80 (or 443 for https) to access your application with your domain name. You can use apache, nginx or haproxy etc.
Also check your firewall if port 3000 is allowed.
Check out this page; http://blog.podrezo.com/making-node-js-work-with-apache/

Related

Jelastic giving 502 on a nodejs application

I'm running a nuxt (running on node engine) website on a simple jelastic environment made of a load-balancer (nginx) and 2 nodejs container. I'm using pm2 as a process manager.
Nuxt is listening to its own ip and port 8080. (as stated here).
When I try to access my website I get a 502 code.
The strange thing is that it used to work, I've tried reverting my project to older working version and nothing works.
If i do a curl to the ip address and port used by nuxt I get back my correct HTML, which indicates to me that it's not an issue with Nuxt anyway.
Jelastic states that it redirects traffic from port 8080 to port 80. I don't know what to and am a bit lost.
What should I check ? Any help is appreciated.
As for the described situation - we've checked the nuxt application deployment on the Jelastic NodeJS node and all seems to work fine.
Please check the next possible issues:
Check if the hostname in the application config is not 'localhost' but '0.0.0.0' (check if it was not erased during the downgrade), details via the link
Check if the JELASTIC_EXPOSE variable is not set to '0', 'DISABLED' or 'FALSE' - in such a case the auto-redirect will not work (more details on auto-redirect here)
Try to set the 'JELASTIC_EXPOSE' variable to the exact value 8080 (or another port that is actually listening by your application)

Deploy Create-React-App on a remote Windows Server

I am an inexperienced intern working with a remote Windows Server and React. The Windows Server is running in the company network. I have created a dynamic React website with a NodeJs backend and React Router. I have only ran it on the localhost development server. I want to try to deploy it on the remote Windows Server and give it a custom domain name (Something which can be accessed like servername/myreactapp/).
So far, I have had no success trying to make it work with IIS, even with a web.config file (I get 404 and 500 errors). I am currently making it work by actually running the development server and the nodejs server in the Windows Server, and I access it through the server IP at port 3000.
An improvement would be to be able to access the port through the server name (like servername:3000, instead of the server_ip:3000), but ideally I want to be able to access it like servername/myreactapp/.
Any help would be appreciated. Thank you very much.
The simple solution would be to run your app on port 80 then you will not have to specify the port number.
The best solution would be to set up Nginx on the server and proxy_pass / route to port 3000.
If its running on localhost, which would be port 80, the url would be like http://your_server_name:80, and would be accessible by anyone on the same network, as long as your authentication allows it.

point node js app to domain

I want to point a domain to the nodejs app running on 3000 port.
Currently my app is hosted on aws. If I have to point my domain to the app, so that I don't have to write <domain>:<port_number> in browser then I think I have two options:
use nginx to proxy the request to port 3000
use aws route 53 for the same
Correct me if I'm wrong and please suggest which one should I opt
Route 53 is just a Domain Name Server.
If you fire up a EC2 instance, you can reach it with the IP address. In addition you get a generic domain to connect to your EC2 instance, something like this: ec2-xx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com
This is ok for testing, but not for a production setup.
So if you want to point a more pleasant domain name to your instance, you need to edit the dns record on your DNS Server. For this you can use Route 53 or any other DNS Service like namecheap or iwantmyname.com.
You can't configure ports there, so use option 1 and set up nginx.
Of cause, as option 3 you can change the port of your nodejs app to port 80, but then you need to run it as root user and that is really bad practice!
So stick with nginx.
More about DNS: https://en.wikipedia.org/wiki/Domain_Name_System

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 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