1

I have a VPS which is running Windows server 2008 datacenter with one Static IP address.

I can access from Internet to my web services by specific port e.g mydomain.com:3000/api and mydomain.com:4000/api. I want to change this web services access address into sub domain method (child) like App1WS.mydomain.com/api and App2WS.mydomain.com/api

update

I add this line to host file

127.0.0.1      mobileapp.myrealdomain.com

Then in nginx, I add these lines at the end

 server {
        listen       80;
        #root html;
        root c:/apps/web;
        server_name  mobileapp.myrealdomain.com;
       location / {
           proxy_pass  "http://127.0.0.1:3000";
        }
}

Then I started my loopback project which is accessible via:

C:\apps\mobileapp>node .
Web server listening at: http://localhost:3000
Browse your REST API at http://localhost:3000/explorer

Then I've add Alias(CNMAE) record to DNS:

alias name: mobileapp
FQDN: mobileapp.myrealdomain.com
FQDN for target host: 127.0.0.1:3000.

From other location on Internet myrealdomain.com loads homepage but still mobileapp.myrealdomain.com showing

server DNS address could not be found.

In VPS mobileapp.myrealdomain.com works properly and loads server up time

{"started":"2017-09-23T10:29:30.626Z","uptime":48.709}
RSA
  • 111
  • 2
  • 1
    See discussions at: https://serverfault.com/questions/774099/iis-sub-domain-reverse-proxy-based-on-host-name and https://serverfault.com/questions/460598/iis-reverse-proxy – TessellatingHeckler Sep 23 '17 at 06:42
  • Dear @tessellatingheckler, thnx I add and update could you please check that. – RSA Sep 23 '17 at 10:36
  • 1
    You can't do this. It's not possible. You are trying to use DNS to redirect someone to a specific port. DNS doesn't have that capability. A DNS record that points to 127.0.0.1:3000 is simply not valid. Only an IP can be specified not a port. – Appleoddity Sep 24 '17 at 01:47
  • dear @appleoddity what should I do. – RSA Sep 24 '17 at 02:50
  • 2
    You'll need a reverse proxy. So all domains are requested from the same IP and port number but the reverse proxy sees the domain being requested and serves the underlying page at the alternate port. Sorry I don't have enough experience to tell you exactly how to set one up, but apparently nginx can do it. – Appleoddity Sep 24 '17 at 02:54

0 Answers0