Skip to content

Instantly share code, notes, and snippets.

@fumiyas
Last active Dec 15, 2021
Embed
What would you like to do?
Apache HTTPD: Default virtualhost definition to deny access to an unexpected server name, but ACME
Alias /.well-known/acme-challenge/ /var/www/acme/.well-known/acme-challenge/
<Directory /var/www/acme/.well-known/acme-challenge>
Require all granted
</Directory>
<VirtualHost 127.0.0.1:80>
<IfModule status_module>
<Location /server-status>
Require ip 127.0.0.1 ::1
SetHandler server-status
</Location>
</IfModule>
<IfModule info_module>
<Location /server-info>
Require ip 127.0.0.1 ::1
SetHandler server-info
</Location>
</IfModule>
</VirtualHost>
<VirtualHost *:80>
RedirectMatch 503 ^(?!/\.well-known/)
ErrorDocument 503 "<html><head><title>503 Service Unavailable</title></head><body><h1>Service Unavailable</h1><p>The requested server name is unknown on this host (your-www-server-nodename.example.com, protocol http, port *:80). Please confirm the server name in the URL.</p></body></html>"
DocumentRoot /var/www/empty
</VirtualHost>
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache2/certs/unknown.crt
SSLCertificateKeyFile /etc/apache2/private/unknown.key
RedirectMatch 503 ^(?!/\.well-known/)
ErrorDocument 503 "<html><head><title>503 Service Unavailable</title></head><body><h1>Service Unavailable</h1><p>The requested server name is unknown on this host (your-www-server-nodename.example.com, protocol https, port *:443). Please confirm the server name in the URL.</p></body></html>"
DocumentRoot /var/www/empty
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment