Welcome! Log In Create A New Profile

Advanced

split traffic based on uri

Posted by frenchviking 
split traffic based on uri
April 25, 2017 11:57AM
Hello,

Working on a new version of a web app, I need to redirect some uri to the new version (including /) while keeping not reworked pages on the old version. Old and new versions are hosted on differents servers.

Currently my solution is half-working because pages (php rendered) are correctly loaded from old or new versions, but all the statics assets (img, css, js) are loaded from old version. I guess this is because of the last location block :

location ~* /uri_v2/ {
try_files $uri $uri/ @v2;
access_log off;
}

location = / {
try_files $uri $uri/ @v2;
access_log off;
}

location / {
try_files $uri $uri/ @v1;
access_log off;
}

location @v1 {
proxy_pass http://v1.webapp.com;
proxy_set_header Host webapp.com;
add_header X-version v1;
add_header X-node $hostname;
}

location @v2 {
proxy_pass http://v2.webapp.com;
proxy_set_header Host webapp.com;
add_header X-version v2;
add_header X-node $hostname;
}

I can't find any logical solution to make this works. How can I tell nginx to load page's related content from the same backend that served the page ?

Thank you.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 311
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready