For past few weeks I'm trying to learn how multiple web servers could be setup under one static IP. I understand that web hosting companies may have a lot of Static IPs but using one IP for one server does not sound efficient.

I read lots of articles, posts and watched videos referring some of them below.

I setup 3 web servers and one windows server to resolve DNS, I forwarded port 53 to Windows Server to listen requests for DNS. But later I came to know that when web request is initialed first DNS Server resolves IP in this scenario it reaches to my public static IP then HTTP request is sent to this IP, at this point I do not understand what approach could be adopted to forward received HTTP request to related web server.

Please note that I understand port forwarding and I was able to achieve it, I also know about reverse proxy, but they do not look like a professional approach, what I'm looking for here is to learn how hosting companies achieve it.

Here are some related post I found

https://serverfault.com/questions/965353/external-requests-to-internal-dns-server https://serverfault.com/questions/435791/internal-dns-server-provide-response-to-external-requests How does DNS work when it comes to addresses after slash?

Here is architecture of my setup I'm sharing here so that you can reference to explain:


If you think more information needed or there is room for improving my question please ask me in comments so that I know what is missing or how can I improve my question.

  • 1
    search terms e.g. "multiple web servers with single IP address". --> Use a proxy. See e.g. dan.langille.org/2020/11/15/…
    – Bodo
    Nov 9, 2022 at 17:13
  • I work for a major web hosting company. Using 1 IP per server is as efficient as it gets. If everyone used 1 IP per website, there would be simply not be enough IPs to use. Leasing IPs are expensive as well. If you host millions of websites, the cost would be astronomical.
    – Keltari
    Nov 9, 2022 at 17:23
  • To further explain @Keltari point, there are literally an infinite number of websites domains (potentially). Yet there are only millions of IPv4 address and billions of IPv6 addresses that can exist. This does not even include the addresses that have to be assigned to the clients viewing those websites and the servers hosting content other than a server daemon like Apache. There isn't another alternative would allow every website to have it's own IP address.
    – Ramhound
    Nov 9, 2022 at 17:34
  • 2
    @Ramhound Nitpick but each element in a hostname is limited to 63 characters and the entire hostname is limited to 253 characters. This gives you a very large number of possible hostnames but it is not infinite. There are potentially billions of IPv4 addresses and IPv6 can (theoretically) give you 3.4 x 10**38 addresses, far larger than billions (like trillion trillion trillion addresses).
    – doneal24
    Nov 9, 2022 at 17:56
  • There's also shared hosting, where a single (physical) web server is serving many different sites. No reverse proxy required.
    – Daniel B
    Nov 10, 2022 at 5:08

1 Answer 1


Yes, hosting companies will often avoid this problem by having enough IP addresses for their servers – each web server would indeed have its own dedicated IP address. All domains hosted on server A will use address A, domains on server B have IP address B, and so on.

Sharing IP addresses has its own inefficiencies – your router needs to support NAT (where normally it doesn't need to), it becomes easier to run out of ephemeral port numbers as you have more connections per IP, etc. So if you have the IP addresses it's more efficient to use them than hoard them.

But other than that, "reverse proxy" remains the answer. (It's pretty much the definition – anything that will "forward received HTTP request to related web server" would be called a reverse proxy.). It is an extremely common method – reverse proxies are used with regular webservers, or with the proxy as a load-balancer (e.g. HAproxy), or with the proxy as a frontend to containers (e.g. Traefik), and so on.

  • I also have OPNSense firewall, is there a specific way to achieve it through a firewall?
    – Tauha
    Nov 9, 2022 at 19:05
  • No. The firewall itself (pf) does not understand HTTP requests nor TLS handshakes, so it cannot redirect the requests based on domain (among other reasons). You'll still need a reverse proxy. Nov 9, 2022 at 19:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .