I've seen people use excessive quotes:
add_header 'Access-Control-Allow-Origin' '*';
I've seen people use no quotes:
add_header Access-Control-Allow-Origin *;
Both work fine as far as I know, so when do you actually have to use quotes?
I've seen people use excessive quotes:
add_header 'Access-Control-Allow-Origin' '*';
I've seen people use no quotes:
add_header Access-Control-Allow-Origin *;
Both work fine as far as I know, so when do you actually have to use quotes?
The exact answer is "never". You can either quote or
\
-escape some special characters like " " or ";" in strings (characters that would make the meaning of a statement ambiguous), sowould work like
In reality: Just use quotes :)
Edit: As some people love to nitpick: The not necessarily complete list of characters that can make a statement ambiguous is according to my understanding of the
nginx
config syntax:and it might be necessary to escape
$
and\
even in quoted strings to avoid variable expansion.Unfortunately, I can't find a complete and authoritative list of such characters in the docs.
Quotes are required for values which are containing space(s) and/or some other special characters, otherwise
nginx
will not recognize them. In your current example quotes make no difference, but anyway quoting values is a good practice/rule of thumbOne snippet from the documentation for 'if':
There is also mention of escaping the source (left-side match) values in a map: