R
Railway2mo ago
Quentin

Trusting proxy IP

Apparently there is some custom header that could be use the get the real client IP and cannot be spoofed (X-Envoy-External-Address or X-Real-Ip ?) Sounds like I cannot trust those custom headers with Laravel https://laravel.com/docs/11.x/requests. Is there some proxy IP that could be trusted ?
Solution:
X-Real-Ip is the header you trust as long as you arent running behind another proxy (cloudflare) https://utilities.up.railway.app/raw...
Jump to solution
12 Replies
Percy
Percy2mo ago
Project ID: N/A
Quentin
QuentinOP2mo ago
N/A
Solution
Brody
Brody2mo ago
X-Real-Ip is the header you trust as long as you arent running behind another proxy (cloudflare) https://utilities.up.railway.app/raw
Quentin
QuentinOP2mo ago
Unfortunately it sounds like you cannot trust this header (which is railway specific I guess ?) with Laravel
No description
Brody
Brody2mo ago
its not railway specific in the slightest X-Forwarded-For can also be trusted, as long as the right most value is used
Quentin
QuentinOP2mo ago
Ok, thank you. Is it guarantee that the container be accessed directory ? So I could basiclly trust the IP sent in the TCP packets (that should be the proxy IP) ?
Brody
Brody2mo ago
you can't access the application without first going through the http proxy
Quentin
QuentinOP2mo ago
With Laravel this should be the way :
No description
Quentin
QuentinOP2mo ago
(not sure if I can change the title to be more Laravel specific)
Brody
Brody2mo ago
make sure you are only trusting the right most value of that header
Quentin
QuentinOP2mo ago
It only trust the IP that is making the request as a proxy. If the container can't be reached from outside it's fine. Thank you !
Brody
Brody2mo ago
I think you are misunderstanding, users can set that header and then your application will receive a list of IPs instead of a single value
Want results from more Discord servers?
Add your server