nanaya
February 09, 2019 05:56AM
Hi,

On Sat, Feb 9, 2019, at 19:50, Reiner Bühl wrote:
> Hi all,
>
> I currently use the following location to redirect every request for a
> resource under /webmail to a seperate server:
>
> location /webmail {
> rewrite ^/webmail(.*) /$1 break;
> proxy_pass http://127.0.0.1:8081;
> proxy_redirect off;
> proxy_set_header Host $host;
> }
>
> This works fine for URLs like /webmail/ or /webmail/<*>. However if the
> URL is just /webmail - no trailing / - then the page itself is served
> from the other web server but all resources like pictures that are
> referenced in that page do not get rewriten. If I call the same page
> with /webmail/, all resources in the page are properly rewritten and
> load correctly.
>
> Can you give me a hint what to change in the rule?
>

The resources are probably in relative path and /webmail is different to /webmail/ - one has base path of / and the other is /webmail/. Request to css/app.css in first path resolves to /css/app.css and the other to /webmail/css/app.css.

I'd do a 301/302 redirect of /webmail to /webmail/ instead.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rewrite doesn't work if location has no trailing /

Reiner Bühl February 09, 2019 05:52AM

Re: Rewrite doesn't work if location has no trailing /

nanaya February 09, 2019 05:56AM

Re: Rewrite doesn't work if location has no trailing /

reibuehl February 09, 2019 08:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 87
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready