refactor(config): clean up default.conf and error.conf - #12
Merged
Conversation
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
There was a problem hiding this comment.
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, undersizedclient_max_body_size, missingupload_store) with supported equivalents and tightens defaults (autoindex off, trailing slash on/cgi-binremoved, DELETE added to/upload). - Removes
error_pageentries inerror.conffor 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The example configs had several semantic issues that the parser silently warned past or accepted as a no-op. After this change
./webservwithCONFIG_DUMP=config/default.confparses with zero warnings, and every directive in the file maps onto something the server will actually do.Changes in
default.conffastcgi_pass 127.0.0.1:9000;cgi .py /usr/bin/python3;client_max_body_size 10000;(~10 KB)client_max_body_size 10M;/uploadhad no upload destinationupload_store ./www/uploads;/uploadallowed only POSTPOST DELETEautoindex onon/autoindex off/cgi-bin/(trailing slash)/cgi-bin/uploadChanges in
error.conferror_page 301 /301.html;— 301 is a redirect, not an error; bodies are discarded.error_page 401 /401.html;anderror_page 501 /501.html;— the referenced HTML files don't exist inwww/. The server's built-in default error pages (subject IV.1) cover those codes.Testing
CONFIG_DUMP=config/default.conf ./webservparses cleanly with no warnings.error.confshow up in the parsederror_pagesmap.cgi .pyandupload_storeare correctly captured on their respective locations.