CrushMFT behind Apache, nginx or a load balancer#
Often something stands between the users and the server: a reverse proxy that shares one address among several web applications, or a load balancer in front of several CrushMFT servers. This page is about what the thing in front must do, and what to set in CrushMFT.
For the opposite, CrushMFT in front of other web servers, see The reverse proxy.
Two kinds of thing in front#
| It works at the level of | Examples | The server learns the user's address by |
|---|---|---|
| connections (TCP) | a network load balancer, HAProxy in tcp mode, nginx stream, CrushBalance |
the PROXY protocol |
| HTTP | Apache, nginx, IIS with ARR, an application load balancer, a web application firewall | the header X-Forwarded-For |
For FTP and SFTP only the first kind works. For the web, both do. Where you can, pass connections through untouched: then TLS ends at CrushMFT, and nothing has to be translated.
What an HTTP proxy must do#
| Need | Why |
|---|---|
pass the Host header on unchanged |
the server builds links, and chooses login pages and domains, by the name the user typed |
add X-Forwarded-For |
so that logs, bans and rules by address see the user, not the proxy |
| not buffer uploads and downloads | a proxy that first collects a whole upload makes large transfers slow, or fails them at its size limit |
| allow large and long requests | no limit on body size; time-outs of minutes to hours, not seconds |
| pass all methods | WebDAV needs PROPFIND, MKCOL, MOVE and the others |
| keep users on one server, in a cluster | by address or by cookie, unless the servers share sessions |
What to set in CrushMFT#
| Setting | Where | What for |
|---|---|---|
| a plain HTTP listener for the proxy | IP / Servers | the proxy holds the certificate and talks plain HTTP to the server. Bind it to an address only the proxy reaches. Leave Redirected to HTTPS:// off on it. |
allow_x_forwarded_host = true |
the server's prefs.XML |
makes the server believe X-Forwarded-For and X-Forwarded-Host. Off on a new server. |
| ReverseProxy Path | the listener's Advanced tab | only when the proxy publishes the server under a path, see below |
Warning
With allow_x_forwarded_host on, the server believes these headers from every connection. Whoever reaches the listener directly can claim any address. Make sure only the proxy can connect to it.
Under a path#
A proxy can publish the server under a path of a larger site, https://www.example.com/crushftp/:
ProxyPass /crushftp/ http://127.0.0.1:8080/
ProxyPassReverse /crushftp/ http://127.0.0.1:8080/
Then enter /crushftp/ as ReverseProxy Path of that listener, so that the server writes its links, redirects and cookies for that path.
A host name of its own, files.example.com, is simpler and more robust than a path. Use a path only when you must.
Examples#
nginx, a host name of its own:
server {
listen 443 ssl;
server_name files.example.com;
client_max_body_size 0;
proxy_request_buffering off;
proxy_buffering off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Apache, with mod_proxy and mod_proxy_http:
ProxyPreserveHost On
ProxyTimeout 3600
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
HAProxy, passing TLS through untouched, for web and SFTP alike:
listen sftp
bind :22
mode tcp
server crush1 10.0.1.11:2222 send-proxy-v2
with Read proxy protocol header info from connecting socket (v2) on that listener.
These are starting points; they were not run for this page. Test uploads of several GB, a WebDAV drive, and a session that is left open over lunch.
Checking#
- Log in through the proxy and look at Connected users: the session must show your own address, not the proxy's.
- Upload a file larger than any limit you know of in the proxy.
- Fail a login a few times on purpose: your address should be banned, not the proxy's. If the proxy is banned, everybody is locked out: the address is not being passed on.
Things to know#
- A web application firewall that inspects uploads will slow them down and may block file contents it does not like. Exempt the upload paths, or pass file transfers around it.
- HTTP/3 ends at whatever speaks it to the browser. Behind an HTTP proxy, leave it off in CrushMFT.
- For several CrushMFT servers behind one address, see the pages on clusters; CrushBalance is the balancer made for it.