0

I've generated https certificates with certbot for website, but didn't pre-generate configs for https automatic redirects from http. Now I'm trying to configure it manually, but with this configuration:

<VirtualHost 127.0.0.1:8080>
        ServerName website.com
        ServerAlias www.website.com
        DocumentRoot /var/www/www-root/data/www/website.com
        ServerAdmin [email protected]
        DirectoryIndex index.php index.html
        AddDefaultCharset off
        SuexecUserGroup www-root www-root
        CustomLog /var/www/httpd-logs/website.com.access.log combined
        ErrorLog /var/www/httpd-logs/website.com.error.log
        <FilesMatch "\.ph(p[3-5]?|tml)$">
                SetHandler application/x-httpd-php
        </FilesMatch>
        <FilesMatch "\.phps$">
                SetHandler application/x-httpd-php-source
        </FilesMatch>
        <IfModule php5_module>
                php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f [email protected]"
                php_admin_value upload_tmp_dir "/var/www/www-root/data/mod-tmp"
                php_admin_value session.save_path "/var/www/www-root/data/mod-tmp"
                php_admin_value open_basedir "/var/www/www-root/data:."
        </IfModule>
        <IfModule php7_module>
                php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f [email protected]"
                php_admin_value upload_tmp_dir "/var/www/www-root/data/mod-tmp"
                php_admin_value session.save_path "/var/www/www-root/data/mod-tmp"
                php_admin_value open_basedir "/var/www/www-root/data:."
        </IfModule>
        SetEnvIf X-Forwarded-Proto https HTTPS=on
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =website.com [OR]
        RewriteCond %{SERVER_NAME} =www.website.com
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,QSA,R=permanent]
</VirtualHost>
<Directory /var/www/www-root/data/www/website.com>
        Options +Includes -ExecCGI
        <IfModule php5_module>
                php_admin_flag engine on
        </IfModule>
        <IfModule php7_module>
                php_admin_flag engine on
        </IfModule>
</Directory>

I'm getting TOO_MANY_REDIRECTS error in the browser. The same effect with

Redirect / https://website.com 

rule. Why it may happen and how to fix it?

2
  • The "too many redirects" error is typically not caused by the VirtualHost entry making the redirect (your plain http VirtualHost 127.0.0.1:8080 without https that redirects to a HTTPS site) but by the target VirtualHost entry i.e. the VirtualHost entry for https//example.com on the default TLS port 443 is probably configured incorrectly. Please check the config for that site.
    – HBruijn
    Mar 18, 2019 at 10:14
  • @HBruijn I don't see any uncommented menitions of 443 port in httpd configs. Grepped them, but found nothing. Mar 18, 2019 at 10:25

0

You must log in to answer this question.

Browse other questions tagged .