Dash
Dash

Reputation: 812

Handle acme-challenge Letsencrypt requests

I have a NodeJs app running behind an Apache configuration using ProxyPass. The HTTPS is setup using Letsencrypt.

As you probably know, to validate a Letsencrypt certificat, we have to handle a request like the one bellow, sent by Letsencrypt server.

http://sub.afakedomain.com/.well-known/acme-challenge/some-random-stringhere

At the moment, the request results into a 404 Not Found because the ProxyPass redirect the request directly to my NodeJs app which didn't handle this request.

I would like to use the Apache solution, but I'm not able to find the right way to do it.

Path to well-known directory

/var/www/html/.well-known/

My vhost setting

<VirtualHost *:80>
             DocumentRoot /var/www/html/fail
             ServerName sub.afakedomain.com
             RewriteEngine on
             RewriteCond %{SERVER_PORT} !^443$
             RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]
</VirtualHost>

<VirtualHost *:443>
             ProxyPreserveHost On
             ProxyRequests Off
             ServerName sub.afakedomain.com
             Proxypass / http://localhost:5555/
             ProxyPassReverse / http://localhost:5555/

             SSLEngine On
             SSLCertificateFile /etc/letsencrypt/live/afakedomain.com/cert.pem
             SSLCertificateKeyFile /etc/letsencrypt/live/afakedomain.com/privkey.pem
             SSLCertificateChainFile /etc/letsencrypt/live/afakedomain.com/chain.pem
             SSLCACertificateFile /etc/letsencrypt/live/afakedomain.com/fullchain.pem
             Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

If you have some suggestions, feel free! Thanks!

Upvotes: 3

Views: 961

Answers (1)

AfroThundr
AfroThundr

Reputation: 1225

If you want to exclude the .well-known directory from being proxied, you just need to add an exclusion. Add the following before the existing ProxyPass lines:

ProxyPass /.well-known/ !

And you should be all set. See the ProxyPass documentation for more info.

Upvotes: 3

Related Questions