logoalt Hacker News

PinkSheeptoday at 3:48 AM0 repliesview on HN

> they were overwhelming a hardcoded Nginx redirect (a simple rewrite regex directive)

1. I wonder how much optimization ngx_http_rewrite_module has? Does it precompile the patterns? LLM said yes, this SO answer [1] says that a JIT config option must be on. I consider "Just in Time" to be a half measure when the config itself is static.

2. From looking at NGINX docs, it looks to me there are some pitfalls to writing these rules. Like you must manually make sure to short-circuit the rewrites to exit early?

3. The caveat of regex is that catastrophically backtracking regexes do look simple. I don't see this issue being talked about enough. See links, if you, the reader, haven't heard of it yet.

[1] https://stackoverflow.com/questions/59284921/how-much-impact...

[3.1] https://joshua.hu/nginx-directives-regex-redos-denial-of-ser...

[3.2] https://en.wikipedia.org/wiki/ReDoS

[3.3] https://infrafolks.com/blog/regex-backtracking-devops/

[3.4] https://www.regular-expressions.info/catastrophic.html

[3.5] https://gixy.io/plugins/regex_redos/