Apache basic authentication except for those Allowed

前端 未结 5 802
一个人的身影
一个人的身影 2020-12-13 19:59

Problem: I have some files under /var/www/files/ that I want them to be accessed from specific IP addresses WITHOUT requiring user/password. However, I would like that any o

5条回答
  •  我在风中等你
    2020-12-13 20:38

    At Apache 2.4+, if you also like to set a fixed username based on the IP block you could use AuthBasicFake directive together with runtime If directive.

    This example with grant direct access to 22.33.44.55/32 and 66.77.88.99/32 and sets username demouser, all others must login.

    
        AuthType Basic
        AuthName "Please enter your username and password"
        AuthUserFile /var/www/files/.htpasswd
    
        
            AuthBasicFake demouser
            Require all granted
        
        
            Require valid-user
        
    
    

提交回复
热议问题