nginx proxy pass subpaths not redirected

References to nginx docs: HttpCoreModule#location, HttpProxyModule#proxy_pass.

There is a better way than using regex (which is slow) for location match. In this case, you could use ^~ to tell nginx to match the given prefix /mail before doing any regex match. You also don’t need that rewrite rule because proxy_pass can do that simple rewrite by itself (by adding a trailing slash / in the upstream server url).

My suggestion is to replace

    location ~ ^/mail(.*)$ {
        rewrite           ^/mail/(.*) /$1 break;
        proxy_pass https://roundcube-host;

by

    location ^~ /mail {
        proxy_pass https://roundcube-host/;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)