Ludo Ludo
Ludo Ludo

Reputation: 23

LetsEncrypt and CakePhp issue

I'm trying to install LetsEncrypt with cakephp and I'm having some issues.Let me describe:

First I'm installing LetsEncrypt on a server with CentOS 6.

As mentioned on several websites it needs a python upgrade from 2.6 to 2.7 as LetsEncrypt needs Python 2.7. Which I did.

Then if I run ./letsencrypt-auto I get

"No installers are available on your OS yet; try running "letsencrypt-auto certonly" to get a cert you can install manually"

I understand that this is normal as there is no installer for CentOS 6.

So I run ./letsencrypt-auto certonly.A window appears.I have the choice between:

  1. Place files in webroot directory
  2. Automatically use a temporary webserver

So I press 1.Then I enter my domain name.And I see:

  1. Enter a new webroot

I press ok and I see my root directory.I select /root

And then I have the following error:

Failed authorization procedure. www.example.com (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.example.com/.well-known/acme-challenge/-CnpDIgxBB9EOH-BCssGOyiunFjnMlGLWhWw9roE4Ds: " 500 Internal Server Error Inter"

IMPORTANT NOTES: - The following errors were reported by the server:

Domain: www.example.com Type: unauthorized Detail: Invalid response from http://www.example.com/.well-known
/acme-challenge/-CnpDIgxBB9EOH-BCssGOyiunFjnMlGLWhWw9roE4Ds:
"
500 Internal Server Error
Inter"

To fix these errors, please make sure that your domain name was
entered correctly and the DNS A record(s) for that domain
contain(s) the right IP address.

And here comes cakephp. As mentioned I'm using cakephp. And it seems that for this specific issue you need to modify htaccess files as mentioned here

I need to add "RewriteRule ^(\.well-known/.*)$ $1 [L]" as the first rewrite rule in the root htaccess and the app/.htaccess

Which I did.

root .htaccess: 

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule ^(\.well-known/.*)$ $1 [L]
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
   AddDefaultCharset UTF-8 
</IfModule>

app/.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^(\.well-known/.*)$ $1 [L]
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*)  webroot/$1    [L]
    AddDefaultCharset UTF-8 
 </IfModule>

But I still have the same problem

Any idea what I did wrong?

Thanks a lot

Upvotes: 0

Views: 1161

Answers (1)

user221931
user221931

Reputation: 1852

Cake's webroot has an .htaccess with a RewriteCond %{REQUEST_FILENAME} !-d rule that means cake will not be called in for any request that matches an actual directory inside webroot.

So just place the .well-known directory and everything else that is needed inside the webroot directory, you should be able to access them fine without messing up with .htaccess.

PS. In some cases the file Let's encrypt requires is not served back as text, in which case you should enable the headers apache module (if not enabled already) and put the following rule in your apache or virtualhost config:

<IfModule mod_headers.c>
  <LocationMatch "/.well-known/acme-challenge/*">
    Header set Content-Type "text/plain"
  </LocationMatch>
</IfModule>

Upvotes: 1

Related Questions