# Implement upstream connection to PHP-FPM
# "phpfpm" here is a name for this upstream connection, which you can customize
# I create a custom upstream connection per vhost, to better segregate PHP processes by vhost
# To do the same, you need a unique upstream name, and a unique filename for your php5-fpm.sock file
upstream phpfpm {
server unix:/var/run/php5-fpm.sock;
#avoid sockets for nginx-fpm on Linux, they are good for BSD
server 127.0.0.1:9000;
}server {
listen 80;
server_name 85.203.117.20;
set $base_root /var/www/kebab;
root $base_root;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/advanced.local.error.log warn;
#access_log /var/log/nginx/advanced.local.access.log main;
charset UTF-8;
index index.php index.html;
location / {
root $base_root/frontend/web;
try_files $uri $uri/ /frontend/web/index.php$is_args$args;
# omit static files logging, and if they don't exist, avoid processing by Yii (uncomment if necessary)
#location ~ ^/.+\.(css|js|ico|png|jpe?g|gif|svg|ttf|mp4|mov|swf|pdf|zip|rar)$ {
# log_not_found off;
# access_log off;
# try_files $uri =404;
#}
location ~ ^/assets/.+\.php(/|$) {
deny all;
}
}
location /admin {
alias $base_root/backend/web/;
# redirect to the URL without a trailing slash (uncomment if necessary)
#location = /admin/ {
# return 301 /admin;
#}
# prevent the directory redirect to the URL with a trailing slash
location = /admin {
# if your location is "/backend", try use "/backend/backend/web/index.php$is_args$args"
# bug ticket: https://trac.nginx.org/nginx/ticket/97
try_files $uri /backend/web/index.php$is_args$args;
}
# if your location is "/backend", try use "/backend/backend/web/index.php$is_args$args"
# bug ticket: https://trac.nginx.org/nginx/ticket/97
try_files $uri $uri/ /backend/web/index.php$is_args$args;
# omit static files logging, and if they don't exist, avoid processing by Yii (uncomment if necessary)
#location ~ ^/admin/.+\.(css|js|ico|png|jpe?g|gif|svg|ttf|mp4|mov|swf|pdf|zip|rar)$ {
# log_not_found off;
# access_log off;
# try_files $uri =404;
#}
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;
fastcgi_pass 127.0.0.1:9000; # proxy requests to a TCP socket
#fastcgi_pass unix:/var/run/php-fpm.sock; # proxy requests to a UNIX domain socket (check your www.conf file)
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $fastcgi_script_name =404;
}
location ~ /\. {
deny all;
}
}