Apache reverse proxy timeout in 60 seconds

apache-2.4reverse-proxytimeout

I have Apache Reverse proxy server which proxies request to my internal Apache server. I am using Apache version 2.4 on Linux platform.

I encountered timeout page and HTTP ERROR 504 whenever back-end Apache server is taking more than 60 seconds ( PHP page waiting for results from Mysql query on back-end Apache server)

Apache Default timeout is set to 300 seconds.

This issue comes only when accessing website through apache reverse proxy. It works well by using internal IP.

I have tried to set below parameters to proxypass but no luck.

ProxyPass / http://internal-ip:8080/ retry=1 acquire=3000 timeout=600 Keepalive=On

I have also tried to ProxyPass on non existing IP which is also showing 504 HTTP ERROR after 60 seconds

Please help me to understand this issue.

<VirtualHost *:80>
 ServerName mywebsite.example.com
 ServerAlias www.mywebsite.example.com
 ProxyPreserveHost On
 DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/mywebsite.example.com-error.log
        CustomLog ${APACHE_LOG_DIR}/mywebsite.example.com-access.log combined

 RewriteCond %{REQUEST_METHOD} !^(GET|POST)$
 RewriteRule .* - [R=405,L]
 ProxyPass /.static-pages !
 ProxyPass / http://<Internal Apache Server IP>/
 ProxyPassReverse / http://<Internal Apache Server IP>/
</VirtualHost>

Best Answer

With ProxyPass directive, you may consider the connectiontimeout parameter.

Refer to Apache httpd mod_proxy documentation: https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#workers

connectiontimeout parameter set the number of seconds Apache httpd waits for the creation of a connection to the backend to complete.

The parameter default value is 60s ...

Related Topic