1

I setup owncloud on a new box recently (Apache/2.4.10 Debian). This was before I got an ssl cert through Let's Encrypt. I've been trying to force http to https, but I always end up with redirect loops. I've googled around and I've tried adding:

Redirect permanent / https://www.example.com

This didn't fix the issue.

My current configuration looks like this:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName www.example.com

        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
        ServerName www.example.com
        DocumentRoot /var/www/owncloud

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

This too gives me a redirect loop.

Also, if I keep just the *:80 virtual host and remove the rewrite part, I can access both http and https without any issues. So I've got that going for me.

Requested Additional Info Section

apachectl -S output:

VirtualHost configuration:
*:80                   www.example.com (/etc/apache2/sites-enabled/ssl-owncloud.conf:1)
*:443                  www.example.com (/etc/apache2/sites-enabled/ssl-owncloud.conf:14)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex rewrite-map: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
5
  • Redirect-checker.org output please Dec 1, 2015 at 4:54
  • Error: no URLs found.
    – Matt R
    Dec 1, 2015 at 4:57
  • That might be the first thing to look at fixing, then.
    – womble
    Dec 1, 2015 at 5:18
  • The configuration is correct even if RewriteCond %{HTTPS} off is not requiered, try to remove your browser cache, check other files configuration like /siteweb-enabled/*.conf and httpd.conf in apache2 folder. Can you update your post with the result of apachectl -S command ?
    – Froggiz
    Dec 1, 2015 at 9:51
  • I've tried this with my second server (apache 2.2), and I am getting the same result. Too many redirects. Is it maybe something the lets encrypt setup is doing?
    – Matt R
    Dec 4, 2015 at 16:53

2 Answers 2

1

The reported configurations are fine. Is it possible other virtual host definitions are hiding?

Would you like to make sure with:

sudo apache2ctl -t -DDUMP_VHOSTS

then? A sane output is:

VirtualHost configuration:
*:80                   www.example.org (/etc/apache2/sites-enabled/000-default.conf:1)
*:443                  www.example.org (/etc/apache2/sites-enabled/default-ssl.conf:4)

(where :1 and :4 is the line number where the vhost is defined).

1
  • Yes, output look exactly like stated
    – Matt R
    Dec 1, 2015 at 15:28
0

Check your owncloud config (/var/www/owncloud/config/config.php), and look for 'forcessl' => true, , and put it to false. This is owncloud option for redirecting http to https traffic without any apache rewrite code.

I hope it helps you.

1
  • forcessl is not in the config
    – Matt R
    Dec 1, 2015 at 15:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .