Owncloud, SSL and Apache
Owncloud 4 was just released. The update was straight forward, although unfortunately each login redirected me again on the login page with no error. Furthermore, the log was rather empty.
After a while, I stumbled over this line within the log:
POST /index.php HTTP/1.1" 302 347
302 means that somewhere a redirect occurred hinting me to the ssl-proxy running on our machine.
Short usage of google pointed me to http://bugs.owncloud.org/thebuggenie/owncloud/issues/oc-762, describing the exact problem I had.
Solution?
1. Adapting the base.php within owncloudinstallation/lib/base.php somewhere near 372 and replacing the line as described in the bug report:
if(isset($_SERVER['HTTPS']) and $_SERVER['HTTPS']<>'') $protocol='https://'; else $protocol='http://';
in
if((isset($_SERVER['HTTPS']) and $_SERVER['HTTPS']<>'') or (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO']==='https')) $protocol='https://'; else $protocol='http://';
2. Adapting the virtualhost of the owncloud location:
# Declare X-Forwarded-Proto as "http" for incoming request
RequestHeader set X-Forwarded-Proto "https"
3. Adapting the virtualhost of the ssl-proxy:
# Overwrite X-Forwarded-Proto declaration for port 443, request are "https"
RequestHeader set X-Forwarded-Proto "https"
That’s it, Owncloud 4 now runs behind our ssl-proxy.