0

I'm having issues where my location is matching a resource one server should be serving because it has the some format as a directory

With this configuration:

location ~ "/web/" {
    set $upstream_host http://webServer;
    set $upstream_port 1234;
    set $upstream_server "${upstream_host}:$upstream_port";

    proxy_pass $upstream_server;

    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;

    proxy_redirect off;
}

location / {
    proxy_pass http://staticHomePageServer;

    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;

    proxy_redirect off;
}

Works - https://my.example.com/web/

Works - https://my.example.com/someOtherSub/web.jpg

Does Not Works - https://my.example.com/web (404)

and if I change

location ~ "/web/" {

to

location ~ "/web" {

Then the sub directory redirects work but I get a 404 on the jpg

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63

1 Answers1

1

have you tried anchoring your regex?

location ~ "^/web" {
criztovyl
  • 181
  • 5