From 5549273ab749aa24656d1b333f5d94c235b2fe65 Mon Sep 17 00:00:00 2001 From: ibrohimovmuhammad2020 Date: Tue, 26 May 2026 16:55:34 +0200 Subject: [PATCH] refactor(config): clean up example configs Issues fixed in default.conf: - Replace fastcgi_pass 127.0.0.1:9000 with cgi .py /usr/bin/python3. FastCGI is a separate protocol the subject does not require; our server speaks simple CGI via fork+exec. The old directive was silently warned and ignored by the parser, which would have been awkward to defend at evaluation. - Bump client_max_body_size from 10000 (~10 KB) to 10M. The previous value was a placeholder from the kanban that would 413 on almost any real upload. - Add upload_store ./www/uploads to /upload so the route actually has somewhere to write uploaded files (subject IV.3 explicitly requires a storage location). - Allow DELETE on /upload so clients can remove their own uploads. - autoindex on -> off on the root location. Avoids accidentally exposing the directory tree if index.html is missing. Specific locations that want browsing can flip it back on individually. - Drop the trailing slash on /cgi-bin so it matches the no-trailing- slash convention used by /upload. Consistency over taste. Issues fixed in error.conf: - Remove error_page 301 /301.html. 301 is a redirect, not an error; the body is discarded by every browser and serving it makes no semantic sense. - Remove error_page 401 and 501 entries that referenced HTML files we don't actually ship in www/. The server's built-in default error pages (subject IV.1) will cover those codes. After this change, ./webserv with CONFIG_DUMP=config/default.conf parses with zero warnings. Related to task: 1.4 --- config/default.conf | 14 ++++++++------ config/error.conf | 5 +---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/config/default.conf b/config/default.conf index 78e8453..b9a6718 100644 --- a/config/default.conf +++ b/config/default.conf @@ -2,21 +2,23 @@ server { listen 8080; server_name localhost; root ./www; - client_max_body_size 10000; + client_max_body_size 10M; location / { allowed_methods GET POST DELETE; index index.html; - autoindex on; + autoindex off; } location /upload { - allowed_methods POST; + allowed_methods POST DELETE; + upload_store ./www/uploads; } - location /cgi-bin/ { + location /cgi-bin { allowed_methods GET POST; - fastcgi_pass 127.0.0.1:9000; + cgi .py /usr/bin/python3; } + include error.conf; -} \ No newline at end of file +} diff --git a/config/error.conf b/config/error.conf index 33698a7..738e5c4 100644 --- a/config/error.conf +++ b/config/error.conf @@ -1,9 +1,6 @@ -error_page 301 /301.html; error_page 400 /400.html; -error_page 401 /401.html; error_page 403 /403.html; error_page 404 /404.html; error_page 405 /405.html; error_page 413 /413.html; -error_page 501 /501.html; -error_page 500 502 503 504 /50x.html; \ No newline at end of file +error_page 500 502 503 504 /50x.html;