-1

got a question and I'm not really sure about it, so I thought I'd ask.

One of the pages on my server contains an ordinary HTML form, that is designed to contact an external script for its form submission.

If I open the page, enter the information in the fields manually, and hit "Process", the external script will, naturally, record my own IP address as a visitor.

What IP address will it record if I automate the form submission by using a server-side method, such as cURL? Does it record the server's IP address, since the server is sending an automated request to the script, or does it record the client's IP address, as usual?

4

1 回答 1

0

如果你依赖$_SERVER["REMOTE_ADDR"],它会记录它在请求中看到的地址,这取决于你的服务器上的路由是如何设置的。如果您将请求发送到 localhost - 那么它实际上会记录 localhost (127.0.0.1) 而不是服务器的外部 IP。

如果您的请求是由一些浏览网络的访问者发起的,那么您有多种跟踪方式:

  1. 在子请求中使用标准X-Forwarded-For标头并跟踪它,就像跟踪任何代理请求一样。(检查是否$_SERVER["HTTP_X_FORWARDED_FOR"]通过并将其用作真实地址,否则回退到$_SERVER["REMOTE_ADDR"])。

  2. 将原始 IP 作为一些自定义参数传递并跟踪它,而不是REMOTE_ADDR何时请求来自某个来源(例如来自本地主机)。

于 2013-08-13T09:15:31.367 回答