I am trying to create Apache virtualhost that is closed for all IP addresses with exception of one IP address and two URLs that should be publicly accessible.
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
ServerAdmin [email protected]
DocumentRoot "/var/www/example.com/app/webroot"
<Directory "/var/www/example.com/app/webroot">
Options FollowSymLinks Includes ExecCGI
AllowOverride All
ErrorDocument 403 "https://example.com/403.php"
DirectoryIndex index.php
</Directory>
<Location "/foo/bar/">
Require all granted
</Location>
<Location "/.well-known/">
Require all granted
</Location>
<Location "/">
Require ip 1.2.3.4
</Location>
SSLProxyEngine on
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /api/ https://host.docker.internal:8443/api/ connectiontimeout=5 timeout=300
ProxyPassReverse /api/ https://host.docker.internal:8443/api/
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
I've tried to change order of Location
tags, but all requests are redirected to ErrorDocument
directive value.
URL /foo/bar/
is rewrited by .htaccess
located in DocumentRoot
(for testing purposes I tried to remove .htaccess
with no effect).
Apache version:
- Server version: Apache/2.4.59 (Debian)
- Server built: 2024-04-05T12:02:26
Apache runs in a Docker container, but it probably has no meaning for the problem.
Q: What is wrong with the configuration?