0

In my /etc/hosts file I added an alias to localhost like this:
127.0.0.1 example.local

My wordpress server is hosted on port 8000 so I use proxy_pass:

server{
   listen 80;
   server_name example.local;

   root /Users/akashagarwal/Downloads/wordpress;

   location / {
     proxy_pass http://127.0.0.1:8000;
     proxy_set_header Host $host;
   }
}

There are two problems that I'm facing.
1. Upon opening http://example.local in my browser, the address bar gets appended with :8000.
2. Upon clicking a link, the host name gets changed to localhost:8000.
What am I doing wrong here?

Running nginx version: nginx/1.10.3 on macOS Sierra 10.12.1.
TIA

1 Answers1

3

The problem definitely isn't nginx: your application is rewriting client accesses to the hostname it knows of. Look for nginx logs, I'ld bet there's a few 30x-code logs, redirecting you somehow, ...

Your config refers to Wordpress, I'ld wild-guess that you should add to your wp-config.php something like:

define('WPSITEURL','http://example.local/');
define('WPHOME','http://example.local/');
SYN
  • 1,751
  • 9
  • 14