Кемеровские программисты php общаются здесь
Anonymous
Nginx `try_files` Directive использует неправильный запасной URI
Сообщение
Anonymous » 11 июн 2025, 00:47
When i am trying to connect one of my services i get
404 Not Found nginx.
I've configured dockerfile and docker-compose well, but have some issues on nginx configs side
the project structure is
Код: Выделить всё
./backend/subscription_service
./backend/subscription_service/Dockerfile
./nginx/nginx.conf
./docker-compose.yaml
< /code>
nginx log: < /p>
2025/06/08 09:24:32 [error] 22#22: *2 open() "/etc/nginx/html/index.php" failed (2: No such file or directory), client: 172.18.0.1, server: localhost, request: "POST /subscription/subscriptions/ HTTP/1.1", host: "localhost"< /code>
172.18.0.1 - - [08/Jun/2025:09:24:32 +0000] "POST /subscription/subscriptions/ HTTP/1.1" 404 153 "-" "PostmanRuntime/7.44.0" "-"
nginx
Код: Выделить всё
server {
listen 80;
server_name localhost;
location /subscription {
alias /var/www/html/public;
index index.php index.html index.htm;
try_files $uri $uri/ /subscription/index.php?$query_string;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass subscription_service:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires max;
log_not_found off;
}
}
}
< /code>
Dockerfile
...
WORKDIR /var/www/html
COPY . /var/www/html
...
EXPOSE 9000
< /code>
docker-compose.yaml
subscription_service:
build:
context: ./backend/subscription_service
dockerfile: Dockerfile
container_name: subscription_service
depends_on:
- subscription_db
volumes:
- ./backend/subscription_service:/var/www/html
- ./backend/subscription_service/bootstrap/cache:/var/www/html/bootstrap/cache
- ./backend/subscription_service/storage:/var/www/html/storage
...
nginx:
image: nginx:alpine
container_name: nginx
ports:
- "80:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./backend/subscription_service:/var/www/html:ro
depends_on:
- subscription_service
< /code>
the project is laravel.
index.php is located in ./backend/subscription_service/public папка
Подробнее здесь:
https://stackoverflow.com/questions/796 ... llback-uri
1749592046
Anonymous
When i am trying to connect one of my services i get 404 Not Found nginx. I've configured dockerfile and docker-compose well, but have some issues on nginx configs side the project structure is [code]./backend/subscription_service ./backend/subscription_service/Dockerfile ./nginx/nginx.conf ./docker-compose.yaml < /code> nginx log: < /p> 2025/06/08 09:24:32 [error] 22#22: *2 open() "/etc/nginx/html/index.php" failed (2: No such file or directory), client: 172.18.0.1, server: localhost, request: "POST /subscription/subscriptions/ HTTP/1.1", host: "localhost"< /code> 172.18.0.1 - - [08/Jun/2025:09:24:32 +0000] "POST /subscription/subscriptions/ HTTP/1.1" 404 153 "-" "PostmanRuntime/7.44.0" "-"[/code] nginx [code]server { listen 80; server_name localhost; location /subscription { alias /var/www/html/public; index index.php index.html index.htm; try_files $uri $uri/ /subscription/index.php?$query_string; location ~ \.php$ { include fastcgi_params; fastcgi_pass subscription_service:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; } location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires max; log_not_found off; } } } < /code> Dockerfile ... WORKDIR /var/www/html COPY . /var/www/html ... EXPOSE 9000 < /code> docker-compose.yaml subscription_service: build: context: ./backend/subscription_service dockerfile: Dockerfile container_name: subscription_service depends_on: - subscription_db volumes: - ./backend/subscription_service:/var/www/html - ./backend/subscription_service/bootstrap/cache:/var/www/html/bootstrap/cache - ./backend/subscription_service/storage:/var/www/html/storage ... nginx: image: nginx:alpine container_name: nginx ports: - "80:80" volumes: - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro - ./backend/subscription_service:/var/www/html:ro depends_on: - subscription_service < /code> the project is laravel. index.php is located in ./backend/subscription_service/public[/code] папка Подробнее здесь: [url]https://stackoverflow.com/questions/79657722/nginx-try-files-directive-uses-an-incorrect-fallback-uri[/url]