Seafile 13 Docker behind Apache2 reverse proxy: "Client sent an HTTP request to an HTTPS server"
I am trying to access Seafile over HTTPS, using the official Seafile Docker image. Seafile runs in a container behind an Apache2 reverse proxy on the host. TLS is terminated by Apache, and the certificate is issued and renewed automatically by certbot, outside of the container.
In /opt/seafile/.env, I set SEAFILE_SERVER_PROTOCOL=https, since the public URL is served over HTTPS. With this setting, the site fails to load and I get the following error:
Client sent an HTTP request to an HTTPS server.If I set the same parameter to http, the site starts and works correctly. However, the download links generated by Seafile then use http:// instead of https://, which the browser blocks (mixed content), so downloads are effectively broken when the site is accessed through the HTTPS frontend.
My understanding is that SEAFILE_SERVER_PROTOCOL=https makes the container expect to handle TLS itself, while in my setup TLS is handled entirely by Apache and the container should only receive plain HTTP from the proxy. I could not find a documented way to keep the container serving plain HTTP while still generating https:// URLs (for example for SERVICE_URL and FILE_SERVER_ROOT).
<IfModule mod_ssl.c>
<virtualhost _default_:443>
DocumentRoot /home/seafile
ServerName mydomain.local
SSLCertificateFile /etc/letsencrypt/live/mydomain.local/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.local/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
RequestHeader set X-Forwarded-Proto "https"
RewriteEngine On
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:1180/$1 [P,L]
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:1180/
ProxyPassReverse / http://127.0.0.1:1180/
</virtualhost>
</IfModule>Expected behavior
Seafile should be reachable over HTTPS through the Apache proxy, and all generated links, including download links, should use https://.
Question
What is the recommended configuration to run the Seafile 13 Docker image behind an external reverse proxy that terminates TLS (Apache2 in my case)? In particular, which settings should be used so that the container listens in plain HTTP but still generates HTTPS URLs? If this is a supported setup, it would be very helpful to have it documented, including the expected Apache headers (such as X-Forwarded-Proto) and the values of SERVICE_URL and FILE_SERVER_ROOT.
Source: haiwen/seafile