Search
 
SCRIPT & CODE EXAMPLE
 

PHP

yii2 advanced nginx

server {
    listen 80;
    server_name advanced.local;

    set $base_root /path/to/advanced;
    root $base_root;

    #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;
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: ext-dom php 7.2 
Php :: object to array in php 
Php :: seed date laravel 
Php :: sleep function in php 
Php :: how to add properties to the request object 
Php :: laravel check if form has errors 
Php :: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `users` add index `users_userable_type_userable_id_index`(`userable_type`, `userable_id`) 
Php :: php color echo 
Php :: call table name in model laravel 
Php :: laravel validation integer 
Php :: laravel group by created_at date only 
Php :: laravel php short if 
Php :: get duplicate value from array php 
Php :: yii2 a href confirm 
Php :: php sleep milliseconds 
Php :: add to url anchor tag laravel with variable 
Php :: redirect 301 wordpress 
Php :: check image exist or not in laravel 
Php :: ipn listener paypel php 
Php :: override Telescope in laravel 
Php :: xampp check php version 
Php :: laravel get extension from url 
Php :: Wordpress SVG Manually - function.php 
Php :: php post curl json 
Php :: cart icon in woocommerce 
Php :: laravel with trashed 
Php :: magento 2 get collection 
Php :: php string contains string 
Php :: email php using html 
Php :: create variable in laravel blade 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =