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

Performance improvements (1/3) to example-advanced.nginx.conf #1709

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

nisbet-hubbard
Copy link
Contributor

@nisbet-hubbard nisbet-hubbard commented Nov 9, 2024

This is the first of three projected PRs meant to close #1704. The patch is separated out to make testing easier. The second and third parts will cover security headers and load balancing (between workers/cores) respectively.

This patch consists of standard optimisations to nginx configuration and regex:

  1. Using return instead of rewrite to avoid interpreting ^(.*)$ and creating additional variable. https://blog.nginx.org/blog/creating-nginx-rewrite-rules
  2. Using non-capturing groups where nothing needs to be saved to variables.
  3. Simplifying \/ to / as nginx doesn’t use forward slash as regex delimiter. https://www.f5.com/company/blog/nginx/regular-expression-tester-nginx
  4. Removing redundant .*$ as .* and $ cancel each other out.
  5. Using exact (=) or prefix (^~) match instead of regex match whenever it’s possible to preserve the same semantics, as both terminate the search immediately on match before any regex gets searched.

Returns 404 when using exact match without slash
@mathilde-cryptpad mathilde-cryptpad added the Reverse proxy Web server or reverse proxy issues label Nov 12, 2024
@mathilde-cryptpad mathilde-cryptpad changed the base branch from main to staging November 12, 2024 10:10
@mathilde-cryptpad mathilde-cryptpad added the Ready to Test This PR is ready to be tested label Nov 14, 2024
@mathilde-cryptpad mathilde-cryptpad self-assigned this Dec 2, 2024
@mathilde-cryptpad
Copy link
Contributor

@nisbet-hubbard thanks a lot for your contribution! We tested your changes on our staging environment and everything looks good. It'll be part of next release. 😊👍🏻

@mathilde-cryptpad mathilde-cryptpad merged commit 08c662d into cryptpad:staging Dec 9, 2024
@mathilde-cryptpad mathilde-cryptpad removed the Ready to Test This PR is ready to be tested label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reverse proxy Web server or reverse proxy issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance improvements to example-advanced.nginx.conf
2 participants