문제

I am trying to get PHP to execute a curl connection to another server. To connect 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top