【问题标题】:How to setup a local xampp behind my company's proxy如何在我公司的代理后面设置本地 xampp
【发布时间】:2025-12-17 20:25:01
【问题描述】:

我正在尝试通过我的本地 xampp 设置执行 curl 请求,但我的公司有一个防火墙代理需要在端口 8080 上进行身份验证。我可以让 apache 登录到此代理进行身份验证并完成 curl 请求吗?

【问题讨论】:

标签: apache curl amazon-web-services xampp local


【解决方案1】:

你可以在你的 curl 请求中做到这一点

例如,如果您使用 php 进行编码

curl_setopt($this->ch, CURLOPT_PROXY, "http://proxy");
curl_setopt($this->ch, CURLOPT_PROXYPORT, 8080);

您可能还需要使用 CURLOPT_PROXYAUTH

或者您可能想尝试设置 HTTP_PROXY ENV 变量

【讨论】:

  • 这有效: curl_setopt($ch, CURLOPT_PROXY, "proxy");curl_setopt($ch, CURLOPT_PROXYUSERPWD, "username:password"); curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
  • 如何设置 HTTP_PROXY ENV?这会默认所有 PHP 发出的请求都使用它吗?
  • 在 XAMPP 安装中,您可以通过在 块中添加以下行来在 ./apache/conf/extra/http-xampp.conf 文件中设置 HTTP_PROXY ENV 变量: SetEnv HTTP_PROXY "username:pass@serveraddress:portnumber"
【解决方案2】:

设置 HTTP_PROXY

导出 http_proxy=http://proxy:8080/

【讨论】:

  • 如何设置用户名和密码?顺便说一句,这是 Windows 上的 xampp 设置。我会使用htaccess吗?怎么样?