We plan to upgrade our web application from php native based application to PHP Framework based (Laravel) to enhance application security and performance. My task is to split traffic where every request pointed to domain app.localhost
without postfix /v3
still forwarded to old application on php-native
web server node, and proxy all request with /v3
path to laravel
web server node. Below is my configuration that resulting all asset (css and js) and URL generated by Laravel pointed to root path.
Laravel generated URL pointed to old application
Front Proxy (Public Network)
server {
listen 80;
listen [::]:80;
server_name app.localhost;
# PHP Native APP
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://php-native/;
}
# Laravel (APP v3)
location /v3/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://laravel/;
}
}
Web Servers (Private Network)
php-native
Web Server
server {
listen 80;
listen [::]:80;
server_name app.localhost;
root /usr/share/nginx/html/webapp/app;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass php56-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/webapp/app/$fastcgi_script_name;
include fastcgi_params;
}
}
laravel
Web Server
server {
listen 80;
server_name app.localhost;
root /usr/share/nginx/html/webapp/app-v3/public;
index index.php index.html index.htm;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass php74-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/webapp/app-v3/public/$fastcgi_script_name;
include fastcgi_params;
}
}
Thanks
Update
My question is: how to split the traffic, so any request pointed to app.localhost
still forwarded to php-native
web server and all request pointed to app.localhost/v3
pointed to laravel
web server ?