Serve different pages for different IP

magal nginx-forum at
Wed Dec 24 15:16:28 UTC 2014

Thank you.

My configurations were:


root /path_to_root1;

if ($remote_addr = xx.xx.xx.xx) {

set $document_root      /path_to root2;


map $remote_addr $document_root {

default  /path_to_root1;

xx.xx.xx.xx /path_to root2;



geo $document_root {

default /path_to_root1;
xx.xx.xx.xx /path_to_root2;

I tryed the three ways you suggested but nginx always answered:

nginx: [emerg] the duplicate "document_root" variable.

My configuration would be to have one document_root for a specific IP and
another for the rest of the world.

Did i make any mistake in my configuration?

thank you

Posted at Nginx Forum:,255744,255775#msg-255775

More information about the nginx mailing list