Nginx authentication except those on local network

ぐ巨炮叔叔 提交于 2019-12-07 05:33:36

问题


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.


回答1:


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 ;)



来源:https://stackoverflow.com/questions/14505799/nginx-authentication-except-those-on-local-network

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!