Nginx бросает 404 при попытке получить доступ к сервисуPhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Nginx бросает 404 при попытке получить доступ к сервису

Сообщение 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

Код: Выделить всё

./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 ... he-service
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»