diff --git a/.docker/nginx.conf b/.docker/nginx.conf deleted file mode 100644 index 8fe03dbc7..000000000 --- a/.docker/nginx.conf +++ /dev/null @@ -1,36 +0,0 @@ -worker_processes auto; - -error_log /dev/stderr notice; -pid /tmp/nginx.pid; - -events { - worker_connections 1024; -} - -http { - proxy_temp_path /tmp/proxy_temp; - client_body_temp_path /tmp/client_temp; - fastcgi_temp_path /tmp/fastcgi_temp; - uwsgi_temp_path /tmp/uwsgi_temp; - scgi_temp_path /tmp/scgi_temp; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - set_real_ip_from 172.16.0.0/16; - real_ip_recursive on; - real_ip_header X-Forwarded-For; - - log_format main '$http_x_real_ip - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /dev/stdout main; - - sendfile on; - keepalive_timeout 65; - - gzip on; - - include /etc/nginx/conf.d/*.conf; -} diff --git a/.docker/templates/default.conf.template b/.docker/templates/default.conf.template deleted file mode 100644 index 8f789dca5..000000000 --- a/.docker/templates/default.conf.template +++ /dev/null @@ -1,52 +0,0 @@ -server { - listen ${NGINX_PORT}; - server_name localhost; - - root ${NGINX_WEB_ROOT}; - - client_max_body_size ${NGINX_MAX_BODY_SIZE}; - - # This also needs to be set in the single server tag and not only in http. - set_real_ip_from 172.16.0.0/16; - real_ip_recursive on; - real_ip_header X-Forwarded-For; - - location / { - # try to serve file directly, fallback to index.php - try_files $uri /index.php$is_args$args; - } - - # Screen client online check should just serve static files - location /client/online-check { - index index.html index.htm; - } - - # Protect files and directories from prying eyes. - location ~* \.(engine|inc|install|make|module|profile|po|sh|.*sql|.tar|.gz|.bz2|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$ { - deny all; - return 404; - } - - location ~ ^/index\.php(/|$) { - fastcgi_buffers 16 32k; - fastcgi_buffer_size 64k; - fastcgi_busy_buffers_size 64k; - - fastcgi_pass ${NGINX_FPM_SERVICE}; - fastcgi_split_path_info ^(.+\.php)(/.*)$; - include fastcgi_params; - - fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; - fastcgi_param DOCUMENT_ROOT $realpath_root; - - internal; - } - - location ~ \.php$ { - return 404; - } - - # Send log message to files symlinked to stdout/stderr. - error_log /dev/stderr; - access_log /dev/stdout main; -} diff --git a/CHANGELOG.md b/CHANGELOG.md index d64e65aa9..40de967f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ All notable changes to this project will be documented in this file. - Added vitest for frontend unit tests. - Updated infrastructure and image build for mono-repo. - Fixed nginx static-file location to fall back to PHP so LiipImagineBundle can generate missing thumbnails (#370). +- Unified nginx config: dev compose now mounts the production template/nginx.conf so local matches deployed behavior (#370). - Annotated `.env` so it serves as the canonical, self-documenting Symfony env example, with a CI check that enforces it stays in sync with `config/`. diff --git a/docker-compose.server.yml b/docker-compose.server.yml index 614d67b10..d9a04931f 100644 --- a/docker-compose.server.yml +++ b/docker-compose.server.yml @@ -29,14 +29,15 @@ services: depends_on: - phpfpm volumes: - - ./.docker/templates:/etc/nginx/templates:ro - - ./.docker/nginx.conf:/etc/nginx/nginx.conf:ro + - ./infrastructure/nginx/etc/templates:/etc/nginx/templates:ro + - ./infrastructure/nginx/etc/nginx.conf:/etc/nginx/nginx.conf:ro - .:/app environment: NGINX_FPM_SERVICE: ${COMPOSE_PROJECT_NAME}-phpfpm-1:9000 NGINX_WEB_ROOT: /app/public NGINX_PORT: 8080 NGINX_MAX_BODY_SIZE: 5M + NGINX_SET_REAL_IP_FROM: 172.16.0.0/12 labels: - "traefik.enable=true" - "traefik.docker.network=frontend" diff --git a/docker-compose.yml b/docker-compose.yml index b5c08946d..d2b8da507 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -57,13 +57,15 @@ services: ports: - "8080" volumes: - - ./.docker/templates:/etc/nginx/templates:ro + - ./infrastructure/nginx/etc/templates:/etc/nginx/templates:ro + - ./infrastructure/nginx/etc/nginx.conf:/etc/nginx/nginx.conf:ro - .:/app environment: NGINX_FPM_SERVICE: ${COMPOSE_PROJECT_NAME}-phpfpm-1:9000 NGINX_WEB_ROOT: /app/public NGINX_PORT: 8080 NGINX_MAX_BODY_SIZE: 5M + NGINX_SET_REAL_IP_FROM: 172.16.0.0/12 labels: - "traefik.enable=true" - "traefik.docker.network=frontend" diff --git a/infrastructure/nginx/Dockerfile b/infrastructure/nginx/Dockerfile index 5bf5c00f7..934e95839 100644 --- a/infrastructure/nginx/Dockerfile +++ b/infrastructure/nginx/Dockerfile @@ -72,7 +72,8 @@ ENV APP_CLIENT_PATH=/app \ APP_API_PATH=/var/www/html \ NGINX_PORT=8080 \ NGINX_SET_REAL_IP_FROM=172.17.0.0/16 \ - NGINX_MAX_BODY_SIZE=10m + NGINX_MAX_BODY_SIZE=10m \ + NGINX_WEB_ROOT=/var/www/html/public WORKDIR ${APP_API_PATH} diff --git a/infrastructure/nginx/etc/templates/default.conf.template b/infrastructure/nginx/etc/templates/default.conf.template index 7902373a6..ebb38d514 100644 --- a/infrastructure/nginx/etc/templates/default.conf.template +++ b/infrastructure/nginx/etc/templates/default.conf.template @@ -8,7 +8,7 @@ server { listen [::]:${NGINX_PORT}; server_name localhost; - root /var/www/html/public; + root ${NGINX_WEB_ROOT}; index index.php index.html; # Health check endpoint