R
R
Rolls Over2019-11-09 14:48:51
Nginx
Rolls Over, 2019-11-09 14:48:51

502 Bad Gateway nginx/1.17.5 Yii2, what's the problem?

server {
    listen       80;
    server_name  localhost;

    set $base_root "мой рут";

    # set $base_root /;

    # set $base_root /usr/share/nginx/academy.smartworld.team/; 

    root $base_root;

    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;

        location ~ ^/assets/.+\.php(/|$) {
            deny all;
        }
    }

    location /admin {
        alias $base_root/backend/web/;

        try_files $uri /backend/web/index.php$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 fastcgi_params;
        fastcgi_pass unix:/run/php/php7.1-fpm.sock;
    }

    location ~ /\. {
        deny all;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2019-11-09
@ky0

set $base_root "мой рут";- it's kind of a bug. When declaring a variable, the $ prefix is ​​not needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question