Skip to content

Instantly share code, notes, and snippets.

@chrisk8er
Created December 8, 2022 04:28
Show Gist options
  • Save chrisk8er/e806b536e17f999d7121d04e445c76ff to your computer and use it in GitHub Desktop.
Save chrisk8er/e806b536e17f999d7121d04e445c76ff to your computer and use it in GitHub Desktop.
Apache proxy error Permission denied

When you're setup a proxy reverse on virtual host. sometimes you will counter with apache http proxy error.

<VirtualHost *:80>
    ServerName domain.com
    ServerAlias www.domain.com
    ProxyPreserveHost On

    ProxyPass / http://localhost:8001/
    ProxyPassReverse / http://localhost:8001/
    
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =domain.com [OR]
    RewriteCond %{SERVER_NAME} =www.domain.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

Error example:

[root@localhost httpd]# cat /var/log/httpd/error_log
[Wed Dec 07 22:53:52.678516 2022] [proxy:error] [pid 42738:tid 140553014413056] (13)Permission denied: AH00957: HTTP: attempt to connect to 0.0.0.0:8001 (0.0.0.0) failed
[Wed Dec 07 22:53:52.678605 2022] [proxy_http:error] [pid 42738:tid 140553014413056] [client 202.146.128.1:53050] AH01114: HTTP: failed to make connection to backend: 0.0.0.0

Solution

Allowing httpd to make a connection

/usr/sbin/setsebool -P httpd_can_network_connect 1

Reference

https://confluence.atlassian.com/bitbucketserverkb/permission-denied-in-apache-logs-when-used-as-a-reverse-proxy-790957647.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment