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
Nginx log:
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"
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;
}
}
}
Dockerfile
...
WORKDIR /var/www/html
COPY . /var/www/html
...
EXPOSE 9000
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
the project is laravel.
index.php is located in ./backend/subscription_service/public
folder