Reverse proxy - rejetto/hfs GitHub Wiki

HFS can work behind a reverse proxy.

First, make sure you have configured this correctly in the 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_pass           http://127.0.0.1:80/;  # 80 here is the port used by HFS
  proxy_http_version   1.1;
  keepalive_timeout    30;
  proxy_read_timeout   1h;  # allow long SSE connections (default is 1 minute)
  proxy_buffering      off;
  proxy_request_buffering off; # stream uploads
  proxy_redirect       off;
  proxy_cache_bypass   1; # don't cache
  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 $host; # 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

  # Support for WebSockets (currently not used)
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
}

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 a 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.

Make HFS be the proxy

All the above was about HFS using a proxy. HFS is not a proxy by itself, but can become one by installing "reverse-proxy" plugin.