My Problem is as below.
I want to configure my domain so that http://mytest.com will point to http://111.222.333.444:8181/
I have few knowledge to configure using Route53 also but not able to solve the mapping with port 8181.
Need kind help to resolve this issue
Thanks in advance
Note : For time being i am not looking for AWS PaaS Elastic Beanstalk for node js deployment
Ajoy
(AWS), an Amazon.com company (NASDAQ:AMZN), today announced that GoDaddy Inc. (NYSE: GDDY) is going all-in on AWS, migrating the vast majority of its infrastructure as part of a multi-year transition.
You actually have to do several things to make your thing work.
Since you registered your hostname with GoDaddy, and you want to use Route53 as your DNS, you have to do several things.
First, go to Route53 and create a hosted zone for your domain. For demonstrative purposes, I will be using stackoverflowexample.com
as my domain.
After you've created your hosted zone, click into it and you should be presented with the NS
and SOA
records. The NS
record lists 4 unique nameservers that you will need to configure with GoDaddy.
The image below is an example of the NS record set (AWS Route53 calls it the delegation set).
Then you will have to go to your registrar and follow their directions to change nameservers for your domain, using the 4 nameservers Route 53 assigned you as your custom nameserver.
Then create a new A
record in route 53 pointing at your elastic IP address. In the end your Route 53 zone will look something like this, with an A
record mapping your domain to your elastic IP address.
After you have set up the DNS records (and waited a while for DNS to propagate), then you should be able to hit your server on port 8181.
But you want to hit it without a port number, so how do you do that?
DNS itself doesn't care about ports, it really just provides information about IP addresses and domain names. What you need now is to set up a proxy or other mechanism to direct traffic on your server. I will provide a few solutions.
nginx
to reverse proxySince you control your own instance, you could install nginx
(a web/proxy server) on the instance and configure it so that when it gets requests, it knows how to direct the traffic.
Here are generic instructions for configuring nginx
for reverse proxy operation.
nginx
example for Debian/UbuntuIf you are using Debian or Ubuntu, a simple set up is as follows:
# Install nginx
sudo apt-get update && sudo apt-get install nginx
# By default, nginx runs a default site on port 80 you don't care about
# This removes the symlink for the default nginx site
sudo rm /etc/nginx/sites-enabled/default
Then you will want to create your own configuration in sites-available
.
sudo vim /etc/nginx/sites-available/mainsite
The contents of your file will look probably like this:
server {
listen 80;
server_name stackoverflowexample.com;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
# Proxy all requests to the NodeJS app on port 8181
proxy_pass http://localhost:8181;
}
}
After you're done, execute the next two steps
# symlink your new nginx config to sites-enabled, which nginx
# automatically discovers and loads.
sudo ln -s /etc/nginx/sites-available/mainsite /etc/nginx/sites-enabled/mainsite
# Reload nginx configuration
sudo service nginx reload
Now try hitting your site without the port - you should reach your application.
AWS offers a load balancer service (at an additional cost of ~$20 USD per load balancer per month) which lets you configure an HTTP and/or HTTPS load balancer for your application, allowing you to map incoming request ports to ports on your instance.
It's also automatically provided to you if you use Elastic Beanstalk.
They have their own tutorial which should help.
I do not do this myself and this is only useful if your instance will only ever host one app that controls all its own routing.
You could run your Node app directly on port 80 without needing a reverse proxy in front. If you go down this route, I'd recommend not allowing the service to run as root
and instead configuring something like authbind
to allow non-privileged access to port 80.
I will defer to other answers like this SuperUser one if you want to bind your service to port 80.
You'll note that I excluded configuring HTTPS. That requires more steps like provisioning an SSL cert, though AWS or LetsEncrypt provide them for free now. Configuration also differs if you're using an Elastic Loadbalancer or a server on your instance, or if you're exposing your app directly.
I suggested nginx
, and I would still recommend it in almost all general cases, but there are multiple different servers you could use to act as a reverse proxy. Other popular ones are haproxy or apache httpd with mod_proxy
.
You can use any AWS public gateway provider such as EC2, ELB, S3 to serve your website or server to the public domain you have on GoDaddy. The AWS usually charges about .51 USD per month to maintain this zone entry as well.
the following steps set up your domain.
Check this tutorial
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With