Skip to content

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

Merged
2 commits merged into
cryptpad:stagingfrom
nisbet-hubbard:patch-5
Dec 9, 2024
Merged

Performance improvements (1/3) to example-advanced.nginx.conf#1709
2 commits merged into
cryptpad:stagingfrom
nisbet-hubbard:patch-5

Conversation

@nisbet-hubbard

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

Copy link
Copy Markdown
Contributor

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
@ghost ghost added the Reverse proxy Web server or reverse proxy issues label Nov 12, 2024
@ghost ghost added this to the Winter release (2024.12.0) milestone Nov 12, 2024
@ghost
ghost changed the base branch from main to staging November 12, 2024 10:10
@ghost ghost added the Ready to Test This PR is ready to be tested label Nov 14, 2024
@ghost ghost self-assigned this Dec 2, 2024
@ghost

ghost commented Dec 9, 2024

Copy link
Copy Markdown

@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. 😊👍🏻

@ghost
ghost merged commit 08c662d into cryptpad:staging Dec 9, 2024
@ghost ghost removed the Ready to Test This PR is ready to be tested label Dec 9, 2024
This pull request was closed.
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

1 participant