0

Does anyone know of a method to use a different server root based on the remote host's IP? This fails with a "root not allowed here" message:

if ($remote_addr = myip) {
    root /some/other/root
}

The goal: serve files from a test directory to my static IP for development.

Unfortunately, I'm migrating a site to wordpress, so it needs to be set up with the correct port/hostname or else I'd simple set up a location /mytestdir {} block or separate server block with a port for testing. Wordpress is annoying in that if you set it up at mydomain.com:1234, it 's a lot of trouble to fix when you move it to mydomain.com (without a port).

I can set up a dev server as mydomain.com on my local network, but I would love to know how to do this in nginx on the same server.

1 Answers1

-1

This question has been answered elsewhere. There seem to be 2 strategies:

  1. Using the nginx geo module. Nginx - How to redirect users with certain IP to special page

  2. Using a variable for the root dir. Nginx document root based on client ip?

Paul
  • 121
  • 2