N
N
neonox2016-01-25 12:03:49
Apache HTTP Server
neonox, 2016-01-25 12:03:49

How to set up http authentication?

Colleagues, welcome!
There is a certain corporate portal which is twisted on the local server.
We began to provide access to external users. For greater security, I also decided to make http authentication using the .htaccess file. The question arose, how to make http authentication only for external users?
For users with IP 192.168.0.0/24 http authentication is not required.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2016-01-25
@neonox

for apache 2.4

<Directory /you_dir/>
<If "%{REMOTE_ADDR} -ipmatch '192.168.0.0/24'">
    Require all granted
</If>
<Else>
    AuthType Basic
    AuthName "Password Protected"
    AuthUserFile <path_to_your_htpasswd_file>
    Require valid-user
</Else>
</Directory>

A
Andrey, 2016-01-25
@VladimirAndreev

backend check user ip by sending 401 response code to external users

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question