Skip to content

refactor(config): clean up default.conf and error.conf - #12

Merged
MukhammadIbrokhimov merged 1 commit into
mainfrom
refactor/example-config-cleanup
May 26, 2026
Merged

refactor(config): clean up default.conf and error.conf#12
MukhammadIbrokhimov merged 1 commit into
mainfrom
refactor/example-config-cleanup

Conversation

@MukhammadIbrokhimov

Copy link
Copy Markdown
Owner

Summary

The example configs had several semantic issues that the parser silently warned past or accepted as a no-op. After this change ./webserv with CONFIG_DUMP=config/default.conf parses with zero warnings, and every directive in the file maps onto something the server will actually do.

Changes in default.conf

Before After Why
fastcgi_pass 127.0.0.1:9000; cgi .py /usr/bin/python3; FastCGI is a different protocol; subject requires simple CGI via fork+exec
client_max_body_size 10000; (~10 KB) client_max_body_size 10M; 10 KB would 413 on almost any real upload
/upload had no upload destination upload_store ./www/uploads; Subject IV.3 mandates a storage location
/upload allowed only POST POST DELETE Clients should be able to remove their own uploads
autoindex on on / autoindex off Avoid leaking the directory tree if index.html disappears
/cgi-bin/ (trailing slash) /cgi-bin Match the no-trailing-slash convention used by /upload

Changes in error.conf

  • Drop error_page 301 /301.html; — 301 is a redirect, not an error; bodies are discarded.
  • Drop error_page 401 /401.html; and error_page 501 /501.html; — the referenced HTML files don't exist in www/. The server's built-in default error pages (subject IV.1) cover those codes.

Testing

  • CONFIG_DUMP=config/default.conf ./webserv parses cleanly with no warnings.
  • All 9 error codes from error.conf show up in the parsed error_pages map.
  • cgi .py and upload_store are correctly captured on their respective locations.

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
Copilot AI review requested due to automatic review settings May 26, 2026 14:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Cleans up the example configuration files so that CONFIG_DUMP=config/default.conf ./webserv parses without warnings and every directive maps to a feature the server actually implements.

Changes:

  • Replaces unsupported/no-op directives in default.conf (fastcgi_pass, undersized client_max_body_size, missing upload_store) with supported equivalents and tightens defaults (autoindex off, trailing slash on /cgi-bin removed, DELETE added to /upload).
  • Removes error_page entries in error.conf for codes whose target HTML files don't exist (401, 501) and for the non-error 301 redirect.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
config/default.conf Switches to supported directives (client_max_body_size 10M, upload_store, cgi), disables autoindex, normalizes /cgi-bin path, allows DELETE on /upload.
config/error.conf Drops error_page lines for 301 (not an error) and 401/501 (no backing HTML files).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MukhammadIbrokhimov
MukhammadIbrokhimov merged commit 47f446a into main May 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants