Serve different pages for different IP

Francis Daly francis at
Tue Dec 23 13:17:30 UTC 2014

On Tue, Dec 23, 2014 at 05:58:00AM -0500, magal wrote:

Hi there,

> I have one domain and I want to serve different pages based on the Client
> IP.
> Nginx refuse different server with same server_name and both location must
> be / . 
> Can you help me?

Set a variable based on the client IP ($remote_addr), using "geo" or
"map" or perhaps "if/set".

Then, depending on what exactly you want to do, perhaps set "root" to
that variable value so that different clients see different parts of
the filesystem.

When I have had to do this before, I only handled the hard-coded first
request the clients made specially, and had the web server issue a
redirect to the client-specific url -- so any client could access any
other client content if it asked for it directly, but the default was
that each client would get its own content after one extra http request.

Francis Daly        francis at

More information about the nginx mailing list