Publishing multiple web servers

I have multiple application servers on my LAN which I am trying to publish so that they would be accessible externally. They run on different ports on different machines. Why? Being a software house, we set up demo and test environments for short durations for clients.

At the moment, I have a Microsoft TMG server. It has the capability to do this as it has an option to publish according to HTTP headers. So I can publish demo1.company.com (forwarding to 10.0.0.1:80), demo2.company.com:8080 (to 10.0.0.2:8080), demo3.company.com:7070 (to 10.0.0.2:9090), etc.

I am trying to replace the TMG with a Mikrotik router. I found one solution on http://forum.mikrotik.com/t/how-to-publish-a-lot-of-web-servers/7077/1 (last answer on that post), but that assumes that all internal servers run on port 80.

Any ideas?

You can adapt the linked solution, but change port for internal host as well … so if a “normal” NAT rule for http looks like this:

add protocol=tcp dst-port=8080 to-address=10.0.0.2 to-ports=80

then just change it to

add protocol=tcp dst-port=8080 to-address=10.0.0.2 to-ports=8080
add protocol=tcp dst-port=7070 to-address=10.0.0.2 to-ports=9090

In all cases the left part of rule (protocol and dst-port) is what original packet is targeting (from client’s machine) and the right part of rule (to-address and to-ports) defines to what those particular packet fields get rewritten (e.g. LAN server IP address and port number on that particular server).

Thanks for the reply.

From what I understand, this would work only if there is a single server on the LAN for each unique port. In that case:

and so on.

I’m trying to route based on host header, as I mentioned.

Then, there’s the case of where a single server on the LAN that hosts multiple sites in Apache on port 80 that it serves according to host headers.

I could forward all port 80 requests to a single server that in turn forwards to individual machines. But then, instead of such a complicated set up, I’d be better off with TMG. It’s the TMG which I’m attempting to replace.

Dont know about TMG - but a slimline NGINX reverse proxy running on even a RPi (or small VM if you have VM hardware) is your only bet to route via host header. The Mikrotik only see’s the TCP stream and can’t really jump into the packets and determine host header - thats read by the webserver when it accepts the connection and starts talking HTTP protocol with the client.