How do I point my custom domain to my IP: Port (21.145.32.76:8080)?

We will have to use a reverse proxy custom domain to IP: Port mapping. Nginx is one of the most popular reverse proxies that are used to do that.

We are assumed that Nginx is installed on your machine. and your application is running on 4200 port on your machine(21.145.32.76). If you want to point the domain to ip address of your machine, we need to follow the following steps.

1). First, add a DNS record for your subdomain.

2) Install Nginx on the machine, where your application/website is running.

3) create new configuration file /etc/nginx/sites-available/mysite and add following content

server { listen 80; server_name mysite.domain.com; location / { proxy_pass http://localhost:4200; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }

Finally, enable it and restart nginx:

sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/mysite sudo service nginx configtest sudo service nginx restart

You should now be able to browse to http://mysite.domain.com and see the contents of http://your-server's-ip:4200.


In this post, We have seen How do I point my custom domain to my IP:Port.