host an nginx site from single configuration file on internal / external networks at the same time

Posted by merpkz@reddit | linuxadmin | View on Reddit | 14 comments

I am trying to host a dokuwiki site from an nginx web server by using only single configuration file, but no matter what I try, it just doesn't work right. Requirements are pretty simple, the site should work like following:

things I have tried so far, but each failing in different way.

My config also has satisfy any clause with whitelisted local network IPs and a basic auth for everyone else - that part at least works reliably. So what am I doing wrong? Can't be that nginx is not capable of doing this simple local/external setup of a site in more straightforward way.