How to restrict access to one Apache web server

I have an Apache web server (v2.4.43) behind my router and I want to restrict the access to it from outside. First, to allow only the https protocol (by redirect) and second, to enable the access just for one single client certificate.

How should I configure the web server for the second topic?

KI

Upvotes: 0

Views: 444

Answers (1)

Pandurang
Pandurang

Reputation: 1741

For Apache 2.4, you would use the Require IP directive. So to only allow machines from single machine or the 192.168.0.0/24 network (range 192.168.0.0 - 192.168.0.255)

<VirtualHost *:80>
    <Location />
      Require ip 192.168.0.0/24
    </Location>
    ...
</VirtualHost>

If you want to authorise certain certificates more specifically, you can check variable SSL variables (e.g. SSL_CLIENT_S_DN_*) and use it in an SSLRequire directive. Refer httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslrequire

Upvotes: 1

Related Questions