Nginx¶
upstream frontend {
hash $scheme$request_uri;
server unix:/var/run/php/php7.4-fpm.sock;
}
upstream backend {
hash $scheme$request_uri;
server unix:/var/run/php/php7.4-backend.sock;
}
server {
set $php_sock frontend;
set $index index.php;
set $base_root /usr/local/wwwr;
listen 192.168.10.4:80;
server_name example.lan;
root $base_root;
charset UTF-8;
index $index index.html;
if ($request_uri ~ "^/(admin)"){
set $php_sock backend;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location / {
root $base_root/frontend/web;
index $index;
try_files $uri $uri/ /frontend/web/$index$is_args$args;
location ~ ^/assets/.+\.php(/|$) {
deny all;
}
}
location /admin {
alias $base_root/backend/web;
index $index;
try_files $uri /backend/web/$index$is_args$args;
location ~ ^/admin/assets/.+\.php(/|$) {
deny all;
}
}
location ~ \.php$ {
rewrite (?!^/((frontend|backend)/web|admin))^ /frontend/web$uri break;
rewrite (?!^/backend/web)^/admin(/.+)$ /backend/web$1 break;
include snippets/fastcgi-php.conf;
fastcgi_pass $php_sock;
fastcgi_read_timeout 1200;
}
}