Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL ip address

Tags:

php

curl

I need to send a curl request with the user's ip address not the server one. I tried this with no luck:

curl_setopt( $ch, CURLOPT_INTERFACE, $ip );

Any ideas?

like image 887
Flatline Avatar asked Sep 09 '25 16:09

Flatline


1 Answers

Ok, so there's no way to safely spoof the ip address of a curl request, but I found a non-safe way, it depends on the server script receiving the request, but it worked for me to trick the API I was making the request to:

curl_setopt( $ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip", "HTTP_X_FORWARDED_FOR: $ip"));

This won't always work, but in this case it worked for me.

Thanks everyone for the help!

like image 165
Flatline Avatar answered Sep 12 '25 04:09

Flatline