That’s not possible for an obvious reason. If this were possible the practice of IP-Spoofing would be extremely easy, after all you could pass by any IP (and still get the answer on behalf of that IP).
The only way this works is if the client accepts these connections, interprets the request and returns the response to your server, which it will never do by default. After all, it is not a proxy.
The alternatives, which I can think of now, are:
- Run the code in the browser via Javascript/WASM, assuming the body of the response is significant. However, it is necessary that your site is authorized by CORS, depending on the case. As this request part of the client the IP of it will be used.
- Run this outside the context of the browser, as an application or executable. In this case you are on the client side, then you can communicate using the user’s IP, without any browser restriction.
and how did you do via php to ask this question and if he altorise to use his ip as proxy ? how would this connection be done
– Cyber Hacker
@Cyberhacker as any other way. For common use (HTTP) is Curl, which has the
CURLOPT_PROXY
(https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html).– Inkeliz