From 34504233b9d690d981acb133b0cf1da1207b95ba Mon Sep 17 00:00:00 2001 From: "m.jalmoudy" Date: Tue, 2 Dec 2025 10:12:09 +0330 Subject: [PATCH] add nginx config file --- docker/nginx/default.conf | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 docker/nginx/default.conf diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf new file mode 100644 index 0000000..88aa141 --- /dev/null +++ b/docker/nginx/default.conf @@ -0,0 +1,35 @@ +server { + listen 80; + server_name localhost; + root /var/www/html; + index index.php index.html index.htm; + + # Custom 404 error page setup + error_page 404 /404.php; + + # 1. Block to handle static files directly + # This location handles assets that should NOT be passed to index.php + # (e.g., CSS, JS, images, fonts). + # You can expand this regex (e.g., |woff|ttf|svg) + location ~* \.(jpg|jpeg|gif|png|ico|css|js)$ { + try_files $uri =404; # Serve the file if found, otherwise return a 404 + } + + # 2. Main location block (Front Controller Pattern) + location / { + # Check if the requested URI ($uri) exists as a file or directory. + # If not, rewrite the request internally to index.php, + # preserving original query arguments ($args). + try_files $uri $uri/ /index.php?$args; + } + + # 3. Block to pass PHP scripts to PHP-FPM + location ~ \.php$ { + # This remains the same to execute any file ending in .php + fastcgi_pass app:9000; # 'app' is the name of your PHP-FPM service + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + } +} \ No newline at end of file