1

I have a Digitalocean VPS and 3 Nodejs (ExpressJs) application. Now I started all of them in same IP and different port like this: - 95.5.5.8:65001 - 95.5.5.8:65002 - 95.5.5.8:65003

But now I want when anybody writes app1.com, the first app 95.5.5.8:65000 shows to him like this:

  • app1.com -> load server in port 65001
  • app2.com -> load server in port 65002
  • app3.com -> load server in port 65003

All of the applications are in same VPS by the same IP, How can I do this, please?

2
  • you need to setup domains to point to vps and Nginx as reverse proxy to express applications there are many guides for this from digital ocean. Commented Apr 17, 2017 at 10:59
  • Could you give me a link? Commented Apr 17, 2017 at 11:04

1 Answer 1

1

You can implement this feature by following steps:

  1. In domain setting page, map app1.com, app2.com and app3.com to 95.5.5.8.
  2. In Nginx, configure 3 proxies for app1.com, app2.com and app3.com in directory /etc/nginx/conf.d/. Here is the proxy file /etc/nginx/conf.d/app1.conf for app1.com:

    server {
        listen       80;
        server_name  app1.com;
        access_log   /var/log/nginx/app1_access.log;
        charset utf-8;
    
        location / {
            proxy_pass      http://95.5.5.8:65001;
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded_For $proxy_add_x_forwarded_for;
        }
    }
    
  3. Restart Nginx.

Sign up to request clarification or add additional context in comments.

1 Comment

@SamiAlMorshedi is your problem solved? If yes, maybe you can "accept" this answer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.