How do I route web requests into my private network depending on the domain in the url?

5,380

Most routers/firewalls allow to redirect traffic based on a certain port, e.g. all SMTP traffic (port 25) is redirected to 192.168.1.1.

But if you have multiple servers to handle your traffic (1 server per domain). You need to install something like a reverse proxy (nginx supports this for HTTP, IMAP, POP3). For instance, all traffic to port 80 is redirected to 192.168.1.2 which runs nginx and depending on the host name will redirect to either localhost or 192.168.1.4.

Share:
5,380

Related videos on Youtube

Matthew Ruston
Author by

Matthew Ruston

Ubuntu member, Kubuntu member

Updated on September 17, 2022

Comments

  • Matthew Ruston
    Matthew Ruston over 1 year

    Scenario:

    Due to limited number of IPs, several domains are resolved into the same IP address. However, these domains may not all run on the same webserver, VM, or even dedicated machine. Therefore, I would like to route the domains at the point of entry into the private network to the right place on condition of the domain in the url.

    How can I do this?

  • Matthew Ruston
    Matthew Ruston over 13 years
    I used to have troubles with mod_proxy, but I might try this again.
  • Matthew Ruston
    Matthew Ruston over 13 years
    I don't think I can use rewrite to the ip-address since this would prevent me to use multiple domains in one VM, however, I probably can rewrite into local sub domains.
  • Jeff Winkworth
    Jeff Winkworth over 13 years
    +1 Nginx is perfect for this as it doesn't use much memory and was designed to handle large numbers of requests. It's pretty easy to setup on most distros.
  • Scott Anderson
    Scott Anderson over 13 years
    +1 Apache is definitely overkill. A simple Nginx proxy will get the job done.
  • Matthew Ruston
    Matthew Ruston over 13 years
    I have installed nginx. It was very easy to install and configure and works very good.