Stefan
Stefan

Reputation: 153

Nginx authentication except those on local network

Coming from apache2 one feature I can not achieve; require authentication only to external access but free access to users on my local network. Any ideas how to handle easily this scenario?

Any help would be appreciated.

Upvotes: 9

Views: 5000

Answers (1)

Michał Kupisiński
Michał Kupisiński

Reputation: 3863

I've deleted my previous answer and would like to suggest a solution I've provided below

I did a little search and found this solution to your problem - In code, where you use auth_basic directive, make such changes:

satisfy    any;
allow      10.0.0.1/8;   // give access for all internal request
deny       all;
auth_basic "....";        // your auth_basic code goes here
auth_basic_user_file ...; // your auth_basic_user_file goes here

How it works? satisfy directive implies that any or all from next coming access rules must be passed to give access to resource. You can find more details here: satisfy

This should fit your problem perfectly ;)

Upvotes: 12

Related Questions