I got 1 static Ip from my ISP.
I got 2 NS (from NS provider)pointing my domain name towards my wan IP.
My question: How do I get server1.domainname.td to reach server 1 inside my network, server2.domainname.td to reach server 2
also placed on my local network(server1 =192.168.1.2 and server2=192.168.1.3) both with use of port 80 only (no portforwarding) (server1=ms win server2=Linux)
Second question: How to reach server3.domainname.td on a server placed outside my network ( another static ip on the internet)

- 1
- 3
-
1For web traffic you typically run a reverse proxy (such as haproxy, but also most webservers can be configured as such, nginx and apache certainly can) on ports 80 and 443 of your single ip-address. The reverse proxy can be configured to map all requests for one URL to one (or more) specific back-end server(s) and all requests for a second URL to a second (group of) back-end server(s). i.e. `www.example.com/a` gets mapped to server-a and `www.example.com/b` to server-b. Alternatively the mapping goes by (sub-)domains i.e. map ` www.a.example.com` to server-a etc. – Bob Jan 16 '20 at 21:05
-
Thanks for your answer, I will tryout nginx. – Svenie Jan 16 '20 at 21:27
2 Answers
If you have only one IP address (hence one port 80
and 443
) you need to use a reverse proxy like nginx to forward requests to the appropriate internal server.
You need to add an A
DNS record for server1.example.com
and server2.example.com
pointing to your public address.
The nginx server might be running on your gateway if you have a good router with OpenWrt firmware or a professional router with proxy capabilities. Otherwise you need to use one of the internal servers and set up a port forwarding from the router to the internal server.
There are a lot of tutorials online on how to configure nginx as reverse proxy.
Remark that this configuration will be slow and prone to failure. For a professional deployment use an external web hosting.

- 5,748
- 2
- 11
- 21
If you are only concerned with web traffic (port 443 or port 80), as others have suggested, use nginx. It's very lightweight. It is what I do.
Assuming linux, in /etc/nginx create a file for your network (eg proxy.conf):
server {
listen 80;
server_name server1.domainname.td;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_pass http://localhost:8085;
}
}
create this stanza in a file (say...route.conf) and place it under /etc/nginx (I assume linux) Add as many stanzas as necessary for your purposes. In /etc/nginx/nginx.conf, include it:
include /etc/nginx/route.conf (do this before the closing bracket)
As for server3, change proxy_pass to your hostname or ip:
proxy_pass http://youroutsideserver ..
UPDATE: As Piotr indicated, place your route.conf file in /etc/nginx/sites-available and symlink to your sites-enabled directory
ln -s /etc/nginx/sites-available/router.conf /etc/nginx/sites-enabled

- 125
- 6
-
Most distributions already have many `include` directives in the default config file. On Debianoids, e.g., you can place your snippet in the `/etc/nginx/sites-enabled` directory (or in `/etc/nginx/sites-available` and symlink to the `sites-enabled` directory). – Piotr P. Karwasz Jan 16 '20 at 21:38
-
Very true. It always helps to double check. I updated the answer to include your input. – KingFish Jan 16 '20 at 21:43