Lets Encrypt + rewrite rule issue

Discussion in 'Installation/Configuration' started by Jiri Benes, Jul 27, 2018.

  1. Jiri Benes

    Jiri Benes Member

    Hello guys,

    I have these 2 rule in my vhost config

    return 301 $scheme://moneypolo.lv$request_uri;
    rewrite (.*) https://moneypolo.com$1 permanent;

    And I´m getting this error if LE tries to renew certificate

    "value": "moneypolo.lv"
    "detail": "Invalid response from http://moneypolo.lv/.well-known/acme-challenge/14XW9Oe_TLWq-N708gVQmpzI2txk4_nbGHYIZLDK1pU: \"\u003c!DOCTYPE html\u003e\n\u003chtml lang='en-GB' data-lang='int-en'\u003e\n\u003chead\u003e\n\t\u003c!-- Google Tag Manager --\u003e\n\t\u003cscript\u003e(function(w,d,s,l,i){w[l]=w[\"",
    "url": "http://moneypolo.lv/.well-known/acme-challenge/14XW9Oe_TLWq-N708gVQmpzI2txk4_nbGHYIZLDK1pU",
    "hostname": "moneypolo.lv",
    "url": "https://moneypolo.lv/.well-known/acme-challenge/14XW9Oe_TLWq-N708gVQmpzI2txk4_nbGHYIZLDK1pU",
    "hostname": "moneypolo.lv",
    "value": "www.moneypolo.lv"
    "detail": "Invalid response from http://www.moneypolo.lv/.well-known/acme-challenge/rGgDYaMgzDg0aOSSk-CgEEVjwF-iTVZSs0jGeAzvIS4: \"\u003c!DOCTYPE html\u003e\n\u003chtml lang='en-GB' data-lang='int-en'\u003e\n\u003chead\u003e\n\t\u003c!-- Google Tag Manager --\u003e\n\t\u003cscript\u003e(function(w,d,s,l,i){w[l]=w[\"",
    "url": "http://www.moneypolo.lv/.well-known/acme-challenge/rGgDYaMgzDg0aOSSk-CgEEVjwF-iTVZSs0jGeAzvIS4",
    "hostname": "www.moneypolo.lv",
    "url": "https://www.moneypolo.lv/.well-known/acme-challenge/rGgDYaMgzDg0aOSSk-CgEEVjwF-iTVZSs0jGeAzvIS4",
    "hostname": "www.moneypolo.lv",
    Domain: moneypolo.lv
    Detail: Invalid response from http://moneypolo.lv/.well-known/acme-challenge/14XW9Oe_TLWq-N708gVQmpzI2txk4_nbGHYIZLDK1pU: "<!DOCTYPE html>
    Domain: www.moneypolo.lv
    Detail: Invalid response from http://www.moneypolo.lv/.well-known/acme-challenge/rGgDYaMgzDg0aOSSk-CgEEVjwF-iTVZSs0jGeAzvIS4: "<!DOCTYPE html>
    2018-07-27 01:02:04,604:WARNING:certbot.renewal:Attempting to renew cert from /etc/letsencrypt/renewal/moneypolo.lv.conf produced an unexpected error: Failed authorization procedure. moneypolo.lv (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://moneypolo.lv/.well-known/acme-challenge/14XW9Oe_TLWq-N708gVQmpzI2txk4_nbGHYIZLDK1pU: "<!DOCTYPE html>
    <script>(function(w,d,s,l,i){w[l]=w[", www.moneypolo.lv (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.moneypolo.lv/.well-known/acme-challenge/rGgDYaMgzDg0aOSSk-CgEEVjwF-iTVZSs0jGeAzvIS4: "<!DOCTYPE html>
    FailedChallenges: Failed authorization procedure. moneypolo.lv (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://moneypolo.lv/.well-known/acme-challenge/14XW9Oe_TLWq-N708gVQmpzI2txk4_nbGHYIZLDK1pU: "<!DOCTYPE html>
    <script>(function(w,d,s,l,i){w[l]=w[", www.moneypolo.lv (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.moneypolo.lv/.well-known/acme-challenge/rGgDYaMgzDg0aOSSk-CgEEVjwF-iTVZSs0jGeAzvIS4: "<!DOCTYPE html>


    Could you lease help me how to update rewrite rule to work with Lets encrypt automatic renewals?

    Thanky a lot!!
     
  2. Etcetera

    Etcetera New Member

    I had a similar issue. For me, adding this snippet before any other rewrite statements, right after the RewriteEngine On statement, seems to do the trick:
    Code:
    RewriteCond %{REQUEST_URI} ^/.well-known/acme-challenge [NC]
    RewriteRule .* - [L]
    (I may be in error, but on first glance I don't think you need to or should use a Return statement there, by the way; you can do that using only Rewrite.)

    Cheers
    Etc
     
    Last edited: Aug 18, 2018

Share This Page