Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove cache control headers for requests handled with an error in Caddy #36590

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

dvj1988
Copy link
Contributor

@dvj1988 dvj1988 commented Sep 27, 2024

Description

Changes

  1. Remove the Cache Control header in the handle errors block. This change makes sure that the Cache control header set for /static/* route is remove in case the file is not found.
  2. Rename the skip_log directive to log_skip.
    As per the caddy server docs

Prior to v2.8.0, this directive was named skip_log, but was renamed for consistency with other directives.

Ref: https://caddyserver.com/docs/caddyfile/directives/log_skip


After this change the following are the response headers for a requests to valid and invalid static file path.

Valid file path (status 200)

curl -I https://ce-36590.dp.appsmith.com/static/js/main.43ec809e.js
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: public, max-age=31536000, immutable
Content-Length: 7859533
Content-Security-Policy: default-src 'self' release-appcdn.appsmith.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; worker-src 'self' blob: release-appcdn.appsmith.com; connect-src * 'self' blob: raw.githubusercontent.com *.intercom.io wss://*.intercom.io *.algolianet.com *.algolia.net api.segment.io *.sentry.io *.hotjar.com maps.googleapis.com fonts.googleapis.com www.gstatic.com fonts.gstatic.com release-appcdn.appsmith.com; img-src * data: blob:; media-src * data: blob:; style-src * 'self' 'unsafe-inline'; font-src * 'self' data:; frame-ancestors *; frame-src * data: blob:
Content-Type: application/javascript
Date: Sun, 06 Oct 2024 12:55:14 GMT
Etag: "d4gwcg4flczk4oggd"
Last-Modified: Fri, 27 Sep 2024 07:43:14 GMT
Status: 200
Strict-Transport-Security: max-age=31536000
Vary: Accept-Encoding
Vary: Accept-Encoding
X-Appsmith-Request-Id: 9ea84a03-e2e7-4ca6-9e78-4eb8a202dbb6
X-Content-Type-Options: nosniff
X-Request-Id: invalid_request_id
X-XSS-Protection: 0
Connection: keep-alive

Invalid file path (status 404)

curl -I https://ce-36590.dp.appsmith.com/static/js/main.js
HTTP/1.1 404 Not Found
Content-Length: 13
Content-Security-Policy: default-src 'self' release-appcdn.appsmith.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; worker-src 'self' blob: release-appcdn.appsmith.com; connect-src * 'self' blob: raw.githubusercontent.com *.intercom.io wss://*.intercom.io *.algolianet.com *.algolia.net api.segment.io *.sentry.io *.hotjar.com maps.googleapis.com fonts.googleapis.com www.gstatic.com fonts.gstatic.com release-appcdn.appsmith.com; img-src * data: blob:; media-src * data: blob:; style-src * 'self' 'unsafe-inline'; font-src * 'self' data:; frame-ancestors *; frame-src * data: blob:
Content-Type: text/plain; charset=utf-8
Date: Sun, 06 Oct 2024 12:56:12 GMT
Status: 200
Strict-Transport-Security: max-age=31536000
X-Content-Type-Options: nosniff
X-Request-Id: invalid_request_id
X-XSS-Protection: 0
Connection: keep-alive

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11202369772
Commit: 0f87242
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Sun, 06 Oct 2024 15:03:47 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

Walkthrough

The changes in this pull request involve modifications to the Caddy configuration script, specifically targeting logging behavior and certificate management. Key updates include renaming logging directives for consistency, enhancing the error handling section to manage Server and Cache-Control headers, and clarifying comments regarding certificate checks. The overall structure of the Caddyfile generation remains unchanged, with additional conditional blocks for custom domains and certificates, while retaining existing functionalities.

Changes

File Path Change Summary
deploy/docker/fs/opt/appsmith/caddy-reconfigure.mjs - Renamed logging directive from skip_log to log_skip.
- Expanded error handling to remove both Server and Cache-Control headers.
- Clarified comments on certificate handling while retaining existing logic.

Possibly related PRs

Suggested labels

skip-changelog, ok-to-test

Suggested reviewers

  • sharat87
  • nidhi-nair
  • rajatagrawal
  • pratapaprasanna

In the realm of code, changes take flight,
Logging and headers, now shining bright.
Certificates checked, with comments so clear,
Caddy's configuration, we hold dear.
A script refined, with clarity in sight,
Let's celebrate this code, oh what a delight! 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b1ed82d and 0f87242.

📒 Files selected for processing (1)
  • deploy/docker/fs/opt/appsmith/caddy-reconfigure.mjs (2 hunks)
🧰 Additional context used
🔇 Additional comments (3)
deploy/docker/fs/opt/appsmith/caddy-reconfigure.mjs (3)

77-77: Class, let's examine these changes in our logging configuration.

Good job on updating the logging directives! You've correctly changed skip_log to log_skip. This modification aligns with Caddy's current syntax standards. Remember, staying up-to-date with the latest conventions is crucial in web server configuration.

Also applies to: 83-83


157-162: Now, let's turn our attention to the error handling section, class.

Excellent work on enhancing our error response headers! By removing both the 'Server' and 'Cache-Control' headers, you've taken a step towards better security practices. This change reduces potential information leakage during error scenarios.

Can anyone tell me why removing these headers might be beneficial? That's right - it makes it harder for potential attackers to gather information about our server setup.


Line range hint 1-262: Class, let's summarize what we've learned from these changes.

Overall, these modifications to our Caddy configuration are commendable. You've demonstrated a good understanding of web server security and best practices. The key improvements are:

  1. Updated logging directives for better consistency.
  2. Enhanced error handling by removing potentially sensitive headers.

These changes will contribute to a more secure and maintainable server configuration. Well done! For your homework, I'd like you to research other ways we might further improve our server's security posture.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dvj1988
Copy link
Contributor Author

dvj1988 commented Sep 27, 2024

/build-deploy-preview skip-tests=true

@github-actions github-actions bot added the Bug Something isn't working label Sep 27, 2024
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11068933614.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36590.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-36590.dp.appsmith.com

Copy link

github-actions bot commented Oct 4, 2024

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Oct 4, 2024
@dvj1988
Copy link
Contributor Author

dvj1988 commented Oct 6, 2024

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Oct 6, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11202294132.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36590.
recreate: .

@dvj1988 dvj1988 marked this pull request as ready for review October 6, 2024 13:36
Copy link

github-actions bot commented Oct 6, 2024

Deploy-Preview-URL: https://ce-36590.dp.appsmith.com

@dvj1988 dvj1988 added the ok-to-test Required label for CI label Oct 6, 2024
@dvj1988 dvj1988 changed the title fix: Add cache control headers only for successful requests fix: remove cache control headers for requests handled with an error Oct 6, 2024
@dvj1988 dvj1988 changed the title fix: remove cache control headers for requests handled with an error fix: remove cache control headers for requests handled with an error in Caddy Oct 6, 2024
@dvj1988 dvj1988 enabled auto-merge (squash) October 6, 2024 16:26
@github-actions github-actions bot removed the Stale label Oct 6, 2024
@dvj1988 dvj1988 merged commit 95010fd into release Oct 7, 2024
68 checks passed
@dvj1988 dvj1988 deleted the fix/cache-control-header-static-files branch October 7, 2024 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants