191095028b469eaa116554b886364f583b912596
By:
migswd

How to disable Letsencrypt redirect all requests to secure HTTPS access

August 16, 2016 1.2k views
Apache Configuration Management Ubuntu

I did the Letsencrypt installation and it works great.
I choose the option to redirect all requests to secure HTTPS access.

I saw those lines added by Letsencrypt in /etc/apache2/sites-available/000-default.conf

        RewriteEngine on
        RewriteCond %{SERVER_NAME} =evolutionary.co
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

Now I want to disable this feature and to have a part of website without ssl.
So I commented those lines and reloaded Apache but the redirection is still active:
http://mydomain.com still redirect to https://mydomain.com

How can I fix that?

2 Answers
migswd August 17, 2016
Accepted Answer

Yes you are right it was a cache problem because of header time config.

Found the solution here :
https://community.letsencrypt.org/t/always-redirect-to-https/10838/2

Seems like you added the HSTS header to your apache conf. This directive tells the browser visiting your site that for the max age configured in the directive, the browser should access your site always using https. So the "problem" is in your browser right now.

In your apache conf you should have/had something like this:

Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"

3.- Recover all the apache and letsencrypt files that you removed, edit apache conf and change the header directive using max-age=0, something like this:
Header always set Strict-Transport-Security "max-age=0; includeSubdomains; preload"

Reload or restart apache and visit again your site, once visited the browser will ignore the htst header and you could access your site using only http.

I modified this directive using max-age=0 and it worked right away....

Please post your /etc/apache2/sites-available/000-default.conf file and .htaccess file if you have one.

One more thing to note is browsers will cache redirects. You may want to test it using incognito mode.

Have another answer? Share your knowledge.