dutchcoders / transfer.sh

Easy and fast file sharing from the command-line.
https://github.com/dutchcoders/transfer.sh
MIT License
15.2k stars 1.53k forks source link

http-auth-ip-whitelist over Sophos UTM proxy #623

Closed michaelscl closed 1 month ago

michaelscl commented 1 month ago

Hi,

In our company we have Sophos UTM as a reverse proxy. I use transfer.sh under the name transfersh.xxxxx.cz over reverese proxy.

I have also disabled authentication for IP 10.10.100.1: --http-auth-ip-whitelist 10.10.100.1

If I access transfer.sh via the name and this proxy, authentication pops up on me:

[transfer.sh]2024/07/16 09:18:51 10.10.100.1:0 - - [2024-07-16T09:18:51+02:00] "PUT /ALUNET%20CED.png HTTP/1.0" 200 "https://transfersh.xxxxx.cz/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0"

If I go to the server directly, outside of the reverse proxy, authentication is skipped:

[transfer.sh]2024/07/16 09:18:54 10.10.100.1:52655 - - [2024-07-16T09:18:54+02:00] "PUT /ALUNET%20CED.png HTTP/1.1" 200  "http://10.8.1.142:8880/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0"

The only difference I see is that if I go through a proxy, transfer.sh identifies me as 10.10.100.1:0 and auth white list doesnt work, but if I go directly, the IP address already shows the port 10.10.100.1:52655 and auth white list works

Could the problem be the source port that Sophos is sending 0? Is this source port also checked port > 0?

I use docker version tag v1.6.1

best regards

Michal

aspacca commented 1 month ago

@michaelscl it is because of the package we use to get the real ip address the request is coming from: https://github.com/tomasen/realip/blob/master/realip.go#L53-L84

it returns X-Forwarded-For, filtering out private address (like "10.10.100.1", indeed), or if no public addres is found, it returns X-Real-Ip, regardless the address is private or not. If none are set it returns http.Request.RemoteAddr

We'll have to find a new package (realip has no update in 8 years), that does not filter out private address.

Not sure how much configurable is Sophos UTM, but if you are able to set X-Real-Ip when requests come from "10.10.100.1" you should have a workaround

michaelscl commented 1 month ago

OK, Sophos has no such capabilities. So I will wait for new versions. m.