-1

I need to connect a domain name with my nodejs application. I used Amazon aws ec2 instance and I run locally node project.

How can I connect my domain name to my nodejs application? I'm using a Windows Server with IIS.

doug65536
  • 6,562
  • 3
  • 43
  • 53
kamaljeet
  • 9
  • 2
  • it is unclear to me if you are trying to reach your node instance on ec2 from your computer. In which case it is only a matter of determining ec2 host, node port and AWS security to let you through – user3802077 May 17 '16 at 13:17

1 Answers1

0

Using Linux Server

You can do this using Nginx Proxy Pass.

First, install Nginx for your distribution

Ubuntu: sudo apt-get install nginx
Fedora/Centos: yum install nginx

Second, configure your Nginx vhost

Edit your config sudo nano /etc/nginx/sites-available/default
add these lines at the very bottom of your file:

server {
  listen 80; ## listen for ipv4; this line is default and implied
  #listen [::]:80 default ipv6only=on; ## listen for ipv6
  root /your_nodejs_app_directory;
  server_name your_domain_name.ex;
  location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host $http_host;
      proxy_pass http://127.0.0.1:7195;
  }
}

remember to change:
/your_nodejs_app_directory with your nodejs app directory
your_domain_name.ex with a domain name that point to your server
:7195 with your NodeJS application port

reboot Nginx

sudo service nginx restart  

Note that, if you are using a RedHat based distribution (like Fedora and Centos), you need to do:

/etc/init.d/nginx restart

or

/etc/init.d/nginx reload

to reboot Nginx. now you can see your NodeJS application by visiting your_domain_name.ex

Using Windows Server

IIS have a method nginx-like named ARR (Application Request Routing). See documentation Here.

Community
  • 1
  • 1
Mirko Brombin
  • 1,002
  • 3
  • 12
  • 34