If a web site is hosted on a public network it can directly be accessed using it IP. If it is hosted on a private network it can still be accesses if the NAT device conducts a port forwarding of some sort.

If there are multiple instances of the web server than the NAT router can perform load balancing.

However what if there are 2 or more un related servers being hosted on a single private space.

How can the traffic be identified as to which server it is destined for in this case.

On any cloud hosting platform, eg AWS. There may be several different servers but just 1 public IP which is used by all incoming traffic (ofcourse AWS has many public IP's).

But in general if the number oif servers exceed the number of public IP's such hat port forwarding cannot be used. Than how can traffic reach its correct destination.

One method I thought was deep packet inspection at the router such that it read the URL in the application header

  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you could provide and accept your own answer.
    – Ron Maupin
    Aug 15, 2017 at 2:55

2 Answers 2


One method I thought was deep packet inspection at the router such that it read the URL in the application header

There is a chicken and egg problem. The application layer headers are not sent until after the TCP connection is established but the process of establishing the connection establishes things like the initial sequence numbers so once the TCP connection is established it can't be diverted using NAT.

So instead an application level proxy is needed which can accept the TCP connection from the client, inspect and possibly modify* the application headers and establish a separate TCP connection to the back-end server.

Note: if your clients support SNI (most modern web browsers do) it is not necessary to decrypt tls traffic when proxying it in this way.

* For example to pass the IP address of the client to the backend server for logging and abuse control.


Multiple public IPs: each server requires a different public IP that clients are forwarded from

Single public IP, easy and ugly setup: run servers on different ports on the public IP address and forward accordingly

Single public IP, more sophisticated setup: install reverse proxy that you forward clients to, separate servers on the application layer and forward from proxy to associated server (correctly speaking, this is not 'forwarding' but a new TCP connection); HTTPS needs to be terminated on the proxy.

  • yes, I know this can be done using multiple IP's. But Can be done without them. Could you elaborate on the third option
    – john
    Jun 16, 2017 at 20:00
  • A reverse proxy takes the URL and forwards server1 to server1, server2 to server2 and so on. For example, check SquidFAQ.
    – Zac67
    Jun 16, 2017 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.