Daanra/laravel-lets-encrypt

NGINX configuration

Closed this issue · 3 comments

e8dev commented

Please share correct nginx configuration. Default Laravel / nginx / apache install give 404 Not Found error when trying to access https://mydomain.com/.well-known/acme-challenge/any8Token8Typed8Here.

If I'm creating Laravel route with "dot" before "well-know" as it requires lets encrypt:

Route::get('/.well-known/acme-challenge/{token}', function (string $token) { <<<=== it doesn't work

Removing dot makes routes reachable but it is not something what lets encrypt expects:

Route::get('/well-known/acme-challenge/{token}', function (string $token) { <<<=== it works

For some reason /.well-known/acme-challenge/{token} is not served by laravel application, nginx doesn't allow this route. (But for example allows next: "/.well-known/acme-challenge")

Approach no. 2:

If nginx settings are not available, please help to understand how to put / return token from default "/public/.well-known/acme-challenge/....." folder

In documentation I clearly see: "You can customise this behavior by setting a custom PathGenerator class in your config under path_generator', but no further explanation how to create custom PathGenerator class.

e8dev commented

It was ISP manager panel which overrides .well-known/acme-challenge/token route in 1) nginx and 2) apache .conf files
If somebody uses ISP manager - just clear configs: 1) /etc/nginx/vhosts-includes/letsencrypt.conf 2) /etc/apache2/conf.d/letsencrypt.conf

Added a small note to the README that mentions this issue

f5uii commented

if you have DebugBar installed and enabled (.env with APP_DEBUG=true), the access at the token will return rubish that causes error 500. So add a simple \Debugbar::disable() in the route, before returning the token content.

Route::get('/.well-known/acme-challenge/{token}', function (string $token) {
\Debugbar::disable();
return Storage::get('public/.well-known/acme-challenge/' . $token);
\Debugbar::enable();
});