So I was configuring nginx today and I hit a weird problem. I was trying to match a location like this:
location ~ ^/([0-9]+)/(.*) {
# do proxy redirects
}
...for URLs like "http://my.domain.com/0001/index.html".
This rule was never matching, despite the fact that it by all rights should. It took me awhile to figure out, based on this documentation, that some characters in regexes need to be quoted. The problem is, the documentation is for rewrites, and it specifically calls out curly braces, not square brackets. After a fair bit of experimentation that involved a lot of swearing, I discovered that I could fix the problem by quoting the regex like so:
location ~ "^/([0-9]+)/(.*)" {
# do proxy redirects
}
Is there a list somewhere of characters that nginx requires quoting regexes with? Or could there be something else going on here that I'm totally missing? This is my first nginx configuration job, so it's very possible I've misunderstood something...
Do you need the number? I'd try a simpler variant first and see if the error is maybe something else.
I'd try if ^/[0-9]+/, or do you need the captured elements?