Skip to content

Instantly share code, notes, and snippets.

@fumiyas
Last active December 15, 2021 03:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fumiyas/0a98fe06590065dbdb9bcfe01d97f4fb to your computer and use it in GitHub Desktop.
Save fumiyas/0a98fe06590065dbdb9bcfe01d97f4fb to your computer and use it in GitHub Desktop.
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