Remove the need for PHP for Apache2, thank you https://serverfault.com/a/938323/336084

master
William Desportes 2024-08-20 09:17:52 +00:00
parent b5bec6c471
commit 082bd5bcb3
1 changed files with 7 additions and 19 deletions

@ -40,37 +40,25 @@ Configure your webserver to respond statelessly to challenges for a given accoun
respond @achallenge "{re.ch.1}.6fXAG9VyG0IahirPEU2ZerUtItW2DHzDzD9wZaEKpqd" respond @achallenge "{re.ch.1}.6fXAG9VyG0IahirPEU2ZerUtItW2DHzDzD9wZaEKpqd"
``` ```
### APACHE ### APACHE
_Tested on Apache 2.4.61_
Add something similar to your `httpd.conf`: Add something similar to your `httpd.conf`:
```apache ```apache
LoadModule php7_module libexec/apache2/libphp7.so
... ...
<VirtualHost *:80> <VirtualHost *:80>
...
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
... ...
<Directory "/PATH/TO/WWW/ROOT/.well-known/acme-challenge/"> <Directory "/PATH/TO/WWW/ROOT/.well-known/acme-challenge/">
RewriteEngine On RewriteEngine On
RewriteRule "^[-_a-zA-Z0-9]+$" "index.php" RewriteRule "^([-_a-zA-Z0-9]+)$" "$1" [E=challenge:$1]
ErrorDocument 200 "%{ENV:challenge}.6fXAG9VyG0IahirPEU2ZerUtItW2DHzDzD9wZaEKpqd"
RewriteRule ^ - [L,R=200]
</Directory> </Directory>
... ...
</VirtualHost> </VirtualHost>
... ...
``` ```
Then add `/PATH/TO/WWW/ROOT/.well-known/acme-challenge/index.php`:
```php
<?php
header("Content-Type: text/plain");
$token = array_pop(explode('/',$_SERVER['REQUEST_URI']));
echo "$token.6fXAG9VyG0IahirPEU2ZerUtItW2DHzDzD9wZaEKpqd";
?>
```
_NOTE that this approach uses PHP but something similar could be done with CGI, Perl, Ruby or pretty much any other server-side language._
### HAPROXY ### HAPROXY
Add the http-request return rule to your configuration: Add the http-request return rule to your configuration:
```haproxy ```haproxy