如何在 PHP/cURL 中使用不同的服务器 IP?
我有一台分配了不同 IP 的服务器,如何指定 cURL 使用不同的 IP?
I have a server with different IPs assigned, how can I specifiy a different IP to be used by cURL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须使用
CURLOPT_INTERFACE
选项:它可以按以下方式使用:
curl_setopt($ch, CURLOPT_INTERFACE, "XXX.XXX.XXX.XXX");
当然,这仅接受来自本地计算机的 IP 和主机名。
You will have to use the
CURLOPT_INTERFACE
option:It can be used in the following manner:
curl_setopt($ch, CURLOPT_INTERFACE, "XXX.XXX.XXX.XXX");
This ofcourse, only accepts IPs and hostnames from your local machine.
此处快速提示
ubuntu 中的示例
更改 /etc/apache2/sites-available/default
Here quick tip
example in ubuntu
change /etc/apache2/sites-available/default