CURL permission denied via browser, works on ssh

Bartu picture Bartu · May 18, 2013 · Viewed 8.1k times · Source

Yesterday I have changed my usergroup/user on my linux host for a group of files. Today I found out that CURL is rising a permission denied (only on browser access, works on SSH)

Couldn't send request: Failed to connect to <server_ip>: Permission denied

file is currently have 777 permissions. But I thinks it is related with user group/user.

ls -all result:

-rwxrwxrwx.  1 baknealdi psaserv    533 May 18 05:14 check.php

Listed users groups;

root:x:0:
psaserv:x:504:apache,psaftp,psaadm,nginx
psacln:x:505:

And I have read somewhere that selinux might be related with it.

sestatus result:

SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 24
Policy from config file:        targeted

I can give any other information, but I really don't know what is related.

Answer

Bartu picture Bartu · May 30, 2013

Simply applying this line of code in the PHP configuration made it;

setsebool -P httpd_can_network_connect 1

which enabled http network connections.