Настройка Docker: B24 + Laravel - ошибка Nginx
Один из сервисов в моём B24 должен быть на чистом Laravel'e. У меня есть настройки Nginx, при котором хорошо работает B24. А также настройки на этом же сервере, при котором Laravel-сервис полностью заменяет B24 и открываются все роуты по пути https://laravel.test/ttt/test_route и тд.
Вот конфиг Nginx в этом случае:
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/nginx/conf.d/sert/cert.crt;
ssl_certificate_key /etc/nginx/conf.d/sert/cert.key;
server_name bitrix;
charset utf-8;
root /var/www/services/ttt/public;
index index.php index.html;
access_log /var/log/nginx/bitrix-access.log;
error_log /var/log/nginx/bitrix-error.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-bitrix:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
}
}
И вот мой стандартный nginx конфиг для B24:
server {
listen 80 deferred reuseport default;
listen [::]:80 deferred reuseport default;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/nginx/conf.d/sert/cert.crt;
ssl_certificate_key /etc/nginx/conf.d/sert/cert.key;
server_name bitrix;
charset utf-8;
root /var/www;
index index.php index.html bitrixsetup.php;
access_log /var/log/nginx/bitrix-access.log;
error_log /var/log/nginx/bitrix-error.log;
add_header X-Content-Type-Options nosniff;
if (!-e $request_filename) {
rewrite ^(.*)$ /bitrix/urlrewrite.php last;
}
rewrite ^([^.]*?\/)\/+(.*)$ $1$2 permanent;
if ($request_uri ~* "^(.*/)index\.php$") {
return 301 $1;
}
location / {
try_files $uri $uri/ @bitrix;
}
location @bitrix {
fastcgi_pass php-upstream;
include fastcgi_params;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root/bitrix/urlrewrite.php;
}
location = /restore.php {
include fastcgi_params;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_send_timeout 21600;
fastcgi_read_timeout 21600;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
client_body_buffer_size 1024m;
client_max_body_size 1024m;
}
location = /favicon.png {
log_not_found off;
access_log off;
}
location = /robots.txt {
log_not_found off;
access_log off;
}
location ~ (/\.ht|/\.git|/\.gitignore|\.settings\.php|/composer|/bitrix/backup|/bitrix/updates|/bitrix/modules|/bitrix/php_interface|/bitrix/stack_cache|/bitrix/managed_cache|/bitrix/html_pages/\.|/upload/1c_exchange|local/modules|local/php_interface|/logs/) {
deny all;
}
location ^~ /upload/support/not_image { internal; }
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|eot|otf|ttf|woff|woff2)$ {
log_not_found off;
access_log off;
expires 30d;
add_header Cache-Control public;
add_header X-Content-Type-Options nosniff;
}
location ~* ^/bitrix/cache { deny all; }
location ~ /upload/ {
client_body_buffer_size 1024m;
client_max_body_size 1024m;
}
location ~ \.php$ {
if ($request_uri ~* "^(.*/)index\.php$") {
return 301 $1;
}
include fastcgi_params;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_send_timeout 21600;
fastcgi_read_timeout 21600;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
error_page 404 /404.html;
location /404.html {}
}
Я попробовал много вариантов, но результат в большинстве случаев одинаковый - на https://laravel.test/ttt/ захожу - открывается базовый роут "/", но если любой другой отличный - ошибка от Б24 (а не от Laravel). .htaccess верный, доступы уже для теста 755 поставил на всё, www-data хозяин этой папки... Вот что перепробовал:
1)
server {
listen 80 deferred reuseport default;
listen [::]:80 deferred reuseport default;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/nginx/conf.d/sert/cert.crt;
ssl_certificate_key /etc/nginx/conf.d/sert/cert.key;
server_name bitrix;
charset utf-8;
root /var/www;
index index.php index.html bitrixsetup.php;
access_log /var/log/nginx/bitrix-access.log;
error_log /var/log/nginx/bitrix-error.log;
add_header X-Content-Type-Options nosniff;
# Laravel часть
location /services/ttt {
alias /var/www/services/ttt/public;
try_files $uri $uri/ /services/ttt/index.php?$query_string;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-bitrix:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
}
# Bitrix часть
location / {
try_files $uri $uri/ @bitrix;
}
location @bitrix {
fastcgi_pass php-upstream;
include fastcgi_params;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root/bitrix/urlrewrite.php;
}
location = /restore.php {
include fastcgi_params;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_send_timeout 21600;
fastcgi_read_timeout 21600;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
client_body_buffer_size 1024m;
client_max_body_size 1024m;
}
location = /favicon.png {
log_not_found off;
access_log off;
}
location = /robots.txt {
log_not_found off;
access_log off;
}
location ~ (/\.ht|/\.git|/\.gitignore|\.settings\.php|/composer|/bitrix/backup|/bitrix/updates|/bitrix/modules|/bitrix/php_interface|/bitrix/stack_cache|/bitrix/managed_cache|/bitrix/html_pages/\.|/upload/1c_exchange|local/modules|local/php_interface|/logs/) {
deny all;
}
location ^~ /upload/support/not_image { internal; }
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|eot|otf|ttf|woff|woff2)$ {
log_not_found off;
access_log off;
expires 30d;
add_header Cache-Control public;
add_header X-Content-Type-Options nosniff;
}
location ~* ^/bitrix/cache { deny all; }
location ~ /upload/ {
client_body_buffer_size 1024m;
client_max_body_size 1024m;
}
location ~ \.php$ {
if ($request_uri ~* "^(.*/)index\.php$") {
return 301 $1;
}
include fastcgi_params;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_send_timeout 21600;
fastcgi_read_timeout 21600;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
error_page 404 /404.html;
location /404.html {}
}
- Вот в этом варианте /services/ttt/ обрабатывается ок, а /services/ttt/test - получаю на белом экране "File not found"
server {
listen 80 deferred reuseport default;
listen [::]:80 deferred reuseport default;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/nginx/conf.d/sert/cert.crt;
ssl_certificate_key /etc/nginx/conf.d/sert/cert.key;
server_name bitrix;
charset utf-8;
root /var/www;
index index.php index.html bitrixsetup.php;
access_log /var/log/nginx/bitrix-access.log;
error_log /var/log/nginx/bitrix-error.log;
add_header X-Content-Type-Options nosniff;
# Laravel часть
location ^~ /services/ttt/ {
alias /var/www/services/ttt/public/;
try_files $uri $uri/ /services/ttt/index.php?$query_string;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php-bitrix:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
}
# Bitrix часть
location / {
try_files $uri $uri/ @bitrix;
}
location @bitrix {
fastcgi_pass php-upstream;
include fastcgi_params;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root/bitrix/urlrewrite.php;
}
location = /restore.php {
include fastcgi_params;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_send_timeout 21600;
fastcgi_read_timeout 21600;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
client_body_buffer_size 1024m;
client_max_body_size 1024m;
}
location = /favicon.png {
log_not_found off;
access_log off;
}
location = /robots.txt {
log_not_found off;
access_log off;
}
location ~ (/\.ht|/\.git|/\.gitignore|\.settings\.php|/composer|/bitrix/backup|/bitrix/updates|/bitrix/modules|/bitrix/php_interface|/bitrix/stack_cache|/bitrix/managed_cache|/bitrix/html_pages/\.|/upload/1c_exchange|local/modules|local/php_interface|/logs/) {
deny all;
}
location ^~ /upload/support/not_image { internal; }
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|eot|ttf|woff|woff2)$ {
log_not_found off;
access_log off;
expires 30d;
add_header Cache-Control public;
add_header X-Content-Type-Options nosniff;
}
location ~* ^/bitrix/cache { deny all; }
location ~ /upload/ {
client_body_buffer_size 1024m;
client_max_body_size 1024m;
}
location ~ \.php$ {
if ($request_uri ~* "^(.*/)index\.php$") {
return 301 $1;
}
include fastcgi_params;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_send_timeout 21600;
fastcgi_read_timeout 21600;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
error_page 404 /404.html;
location /404.html {}
}
В логе nginx/ 192.#.#.# - - [24/Jul/2024:12:21:48 +0300] "GET /services/ttt/test HTTP/1.1" 404 47 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
На всякий случай приложу .htaccess в корне laravel'a
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>