Unsecure access when viewing a PDF

Hi,

I’m unable to view any PDF file from the web interface. In the inspector I can see the PDF view page downloading the file via http instead of https and the browser blocks it:

the request URL is: `http://HOST/seafhttp/repos/UUID/files/Ingegneria/Lezione-17.pdf/?op=download\`

The server is running in http mode with a haproxy in front which handles HTTPS (I will migrate to caddy soon).

I looked at the seahub sources and I think this is where the path is exposed:

This issue occurs because, starting with Seafile version 12.0, the settings SERVICE_URL and FILE_SERVER_ROOT are no longer used. Seafile now determines the correct URLs for file viewing and downloading based on the environment variables SEAFILE_SERVER_PROTOCOL and SEAFILE_SERVER_HOSTNAME.

Even though your HAProxy handles the HTTPS termination, you must explicitly tell Seafile to generate links using the https scheme.

To fix this, please update your environment configuration (typically the .env file if you are using Docker):

  1. Set SEAFILE_SERVER_PROTOCOL=https.
  2. Ensure SEAFILE_SERVER_HOSTNAME is set to your domain name (e.g., seafile.example.com).

After applying these changes, restart your Seafile containers/services. This will ensure that the fileDownloadURL generated by Seahub correctly uses the https protocol, preventing browser blocks.

For more details on these configuration variables, you can refer to the Seafile Admin Manual.

1 Like

That worked, thanks!