Welcome! Log In Create A New Profile

Advanced

Nginx migration to new website page by page

Posted by warzoni 
Nginx migration to new website page by page
July 21, 2016 04:57PM
I am currently trying to perform a page-by-page transition to a new version of my website and stuck with dynamic pages.

Now, I have, say, website http://mywebsite.com located inside www/mywebsite.com

Next, there is a new version under development, located inside www/new.mywebsite.com

It is ready for deployment, but not all of the pages have been implemented so far. So I decided to launch everything that is ready but leave an old version pages where I must.

For example, http://mywebsite.com/page1 has a new version, so it has to be requested from www/new.mywebsite.com. http://mywebsite.com/page2 is not ready - old www/mywebsite.com will be the handler for it.

I know I could write tonns of locations width aliases, but... Is there a better way?

Luckily for me, the static content has a completely different urls, so I created a rule in nginx like "If there is 404 on static, requested from www/mywebsite.com, - look for it inside www/new.mywebsite.com instead of www/mywebsite.com", which works great:

server {
server_name mywebsite.com www.mywebsite.com;
error_page 404 @apache1;
try_files $uri $uri/ @apache1;

location / {
fastcgi_intercept_errors on;
try_files $uri $uri/ @apache1;
}

location @apache1 {
proxy_pass http://new.mywebsite.com:8776;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header Host new.mywebsite.com;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}
}
When I decided to do the same with php (trigger 404 to try files inside www/new.mywebsite.com) I got stuck...
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 90
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