Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proxy timeout with ReWriteRule

There is no way of controlling timeout when proxying by means of ReWriteRule (mod_rewrite) with Apache 2.4.

<VirtualHost "*:443">
  ServerName xxxx
  Use ssl
  RewriteEngine On
  RewriteRule (.*/wms|/openlayers3/.*) http://localhost:8080$1 [P,L]
  RewriteRule .* [F]
</VirtualHost>

I've tried unsuccessfully:

  • Timeout 400
  • ProxyTimeout 400
  • ProxySet
<Proxy "http://localhost:8080/">
  ProxySet connectiontimeout=100 timeout=400
</Proxy>
  • ProxyPass "/" "http://localhost:8080" connectiontimeout=100 timeout=400

The timeout is always 1 minute, no matter which of the above directives I use.

like image 231
david.perez Avatar asked Oct 27 '25 04:10

david.perez


1 Answers

This timeout can be controlled only globally. Change the global Timeout setting in httpd.conf to your preferred value:

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 400

Probably a better way to do this would be to use nginx:

server {
    listen       443;
    server_name  xxxx;
    # ... ssl setup ...

    location ~* /wms$ {
        proxy_pass http://localhost:8080;
        proxy_read_timeout 400;
    }

    location /openlayers3/ {
        proxy_pass http://localhost:8080;
        proxy_read_timeout 400;
    }

    location / {
        return 403;
    }
}

Additional links to nginx documentation so that you understand what's going on in this snippet:

  • location and how regular expressions work in nginx
  • proxy_pass
  • proxy_read_timeout
  • Converting rewrite rules from Apache to Nginx

For the SSL configuration missing in my snippet please also read the documentation.

like image 112
ximaera Avatar answered Oct 30 '25 04:10

ximaera