Почему не срабатывает правило nginx?

Здравствуйте. Или я уже плавлюсь от жары или действительно не работает.
server { 
        server_name  example.com www.example.com;
        listen 443 ssl http2;
        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;    
        charset off;
        index index.php index.html;
        access_log /home/example/example.com/logs/access.nginx.log;
        error_log /home/example/example.com/logs/error.nginx.log notice;

        root /home/example/example.com/www/public;

        location ^~ /static {      
            root /home/example/example.com/app;       
        }
       
        location / {
            include /etc/nginx/auth.conf;
            try_files $uri $uri/ /index.php$is_args$args;
            include /etc/nginx/include/example.com.con[f];
        }
        
        location ~ \.php$ {
            fastcgi_pass   unix:/var/run/example.com.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    
        location ~ ^/assets/.*\.php$ {
            deny all;
        }
        location ~* /\. {
            deny all;
        }  
}

Есть такой конфиг. Там в public живет один из фрейворков (laravel).

Хочу, чтобы урлы /thing (и всё, что ниже их (/thing/any/thing)) открывались из отдельного root,
Т.е. всё, что НЕ /thing* - из основого root, а /thing* из отдельной директории (пусть будет app (лежащей на уровне www)). Содержимое /thing* представляет собой обычную статику (с index.html, там реактовый SPA).

Делаю примерно так:
server { 
        server_name  example.com www.example.com;
        listen 443 ssl http2;
        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;    
        charset off;
        index index.php index.html;
        access_log /home/example/example.com/logs/access.nginx.log;
        error_log /home/example/example.com/logs/error.nginx.log notice;

        root /home/example/example.com/www/public;

        location /thing {      
            alias /home/example/example.com/app;
            try_files $uri $uri/ /index.html$is_args$args;         
        }

        location ^~ /static {      
            root /home/example/example.com/app;       
        }
       
        location / {
            include /etc/nginx/auth.conf;
            try_files $uri $uri/ /index.php$is_args$args;
            include /etc/nginx/include/example.com.con[f];
        }
        
        location ~ \.php$ {
            fastcgi_pass   unix:/var/run/example.com.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    
        location ~ ^/assets/.*\.php$ {
            deny all;
        }
        location ~* /\. {
            deny all;
        }  
}


У меня начинает работаеть /thing и /thing/, но не работает, все что ниже /thing/что-то. Хотя вроде аналогичный конфиг спокойно работает.
Прошу помощи
  • Вопрос задан
  • 61 просмотр
Решения вопроса 1
@dodo512
try_files $uri $uri/ /index.html$is_args$args;

Поменять на
try_files $uri $uri/ /index.html =404;
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы