Reverse proxy - rejetto/hfs GitHub Wiki

HFS can work behind a reverse proxy.

First, be sure you correctly configured this in Admin-panel/Options

Then you need to configure your proxy. Configuration depends on what software you use, but this is an example using nginx exposing HFS under the path /files/ instead of just /. Adjust it to suit your needs.

location /files/ {
  proxy_http_version 1.1;
  keepalive_timeout 30;
  proxy_buffering off;
  proxy_redirect off;
  proxy_max_temp_file_size 0;
  proxy_set_header        X-forwarded-for $proxy_add_x_forwarded_for;  # forward IP address
  proxy_set_header        X-forwarded-host "example.com"; # this is not always necessary, but host is used by some features like "roots"
  proxy_set_header        X-Forwarded-Proto $scheme; 
  proxy_set_header        X-forwarded-prefix "/files"; # the location without final slash
  client_max_body_size    0;  # disable max size for uploads
  proxy_pass      http://127.0.0.1:80/;
}

This is enough, but you may want to configure generated links accordingly:

  • go to Admin-panel > Internet > Address
  • click the Change button
  • enter the final URL of your proxy including the location

Force HTTPS

If you want to have http-to-https redirection with a reverse-proxy, you cannot use the "Force HTTPS" feature of HFS, as this would redirect to the internal HTTPS port. You should configure your proxy to do the job, instead. Try googling.

Cloudflare

Cloudflare, when used as proxy, has a limit on upload size. To avoid this problem, configure HFS to send uploads in chunks. Find the option in Admin-panel > Options > Uploads.