How to Detect and Prevent Apache Open Proxy Vulnerability Using cURL Tests


3 views

An open proxy server can expose your infrastructure to serious security risks, allowing attackers to anonymously route traffic through your system. When Apache is misconfigured as an open proxy, it becomes a potential tool for malicious activities like DDoS attacks or content scraping.

The most effective way to test is using cURL with various target domains through your suspected proxy:

curl -v --proxy http://your-server-ip:80 http://external-site.com

Secure configuration should return:

HTTP/1.1 403 Forbidden (or similar error)
Proxy requests not allowed

Vulnerable configuration might return:

HTTP/1.1 200 OK
[content from external-site.com]

Run multiple tests against different domains:


# Test HTTP site
curl -v --proxy http://your-server:80 http://example.org

# Test HTTPS site
curl -v --proxy http://your-server:80 https://google.com

# Test with different HTTP methods
curl -X POST --proxy http://your-server:80 http://test.com

Add these directives to your httpd.conf or virtual host:


<Proxy *>
    Require all denied
</Proxy>

ProxyRequests Off
ProxyVia Off

Create a bash script for regular testing:


#!/bin/bash
SERVER="your-server-ip"
TEST_URL="http://example.com"

RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" --proxy http://$SERVER:80 $TEST_URL)

if [ "$RESPONSE" == "200" ]; then
    echo "CRITICAL: Open proxy detected!"
    exit 1
else
    echo "Proxy test passed"
    exit 0
fi
  • Regularly audit your Apache modules (mod_proxy, mod_proxy_http)
  • Implement IP-based access controls for sensitive paths
  • Monitor outbound traffic for unusual patterns
  • Keep Apache updated to the latest secure version

Enable detailed logging in Apache to track proxy attempts:


LogLevel debug
CustomLog ${APACHE_LOG_DIR}/proxy.log "%h %l %u %t \"%r\" %>s %b"

An open proxy server allows anyone on the internet to route traffic through your server, which can lead to security vulnerabilities, abuse, and potential blacklisting. Testing your Apache configuration is crucial for security hardening.

The simplest way to test is using cURL with your server as a proxy:

curl -v --proxy http://yourserver:80 http://example.com

If your server is properly secured, you should receive either:

  • 403 Forbidden response
  • Connection refused
  • Authentication required prompt

For comprehensive testing, try these variations:

# Test different protocols
curl --proxy http://yourserver:80 https://google.com

# Test with different ports
curl --proxy http://yourserver:8080 http://example.org

# Test with headers that might bypass protections
curl -H "X-Forwarded-For: 1.2.3.4" --proxy http://yourserver:80 http://test.com

Examine these key Apache configurations:

# In httpd.conf or virtual host files
<IfModule mod_proxy.c>
    ProxyRequests Off
    <Proxy *>
        Require all denied
    </Proxy>
</IfModule>

For regular monitoring, create a Bash script:

#!/bin/bash
SERVER="your.server.ip"
TEST_URL="http://example.com"
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" --proxy http://$SERVER:80 $TEST_URL)

if [[ "$RESPONSE" == "403" ]] || [[ "$RESPONSE" == "407" ]]; then
    echo "Proxy properly secured (Response: $RESPONSE)"
else
    echo "WARNING: Potential open proxy detected (Response: $RESPONSE)"
    exit 1
fi
Response Meaning
200 OK Server is acting as open proxy
403 Forbidden Proxy access denied (secure)
407 Proxy Auth Required Authentication needed (secure)
Connection refused Proxy service not running
  • Regularly audit your Apache modules (disable mod_proxy if unused)
  • Implement rate limiting with mod_ratelimit
  • Monitor logs for suspicious proxy attempts
  • Consider using mod_security for additional protection