开发者

Apache curl via HTTP proxy

开发者 https://www.devze.com 2023-01-27 16:46 出处:网络
I am trying to get PHP to execute a curl connection to another server. To conne开发者_开发问答ct to the server, we need to go via a proxy.

I am trying to get PHP to execute a curl connection to another server. To conne开发者_开发问答ct to the server, we need to go via a proxy. Within bash, we have set the env-variable http_proxy and this works correctly while using the php script from the command-line. However, when attempting to execute curl, or wget from apache, it fails with no errors. The server is configured with SELinux based on Centos defaults. This has been unchanged as I am unsure about SELinux configuration. Has anyone else had a similar issue?


Sorry for the late response. It was to do with SELinux preventing apache to perform calls out to the network. To allow apache to do this, you need to run:

setsebool -P httpd_can_network_connect 1

I was then presented with another related issue where I needed to execute scripts from the command line and couldn't find an appropriate SELinux property so ended up disabling it... ohh well.


the webserver process runs most likely not under the same user as you when you "execute from command line", it will probably not have the same shell environment either. you can however explicitly configure a proxy server in your curl request. if i recall that correctly its the -x switch. you can also pass a lot of arguments. just see the manpage. wget supports proxy as well but as far as i am nut sure about the params you configure. see the manpage as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消