Skip to content

Instantly share code, notes, and snippets.

@yosida95
Created February 9, 2022 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yosida95/eb5d46c39df5909dd94bc044e4f19cd1 to your computer and use it in GitHub Desktop.
Save yosida95/eb5d46c39df5909dd94bc044e4f19cd1 to your computer and use it in GitHub Desktop.
NGINX config pitfall
http {
server {
server_name example.net;
listen 80;
types {}
default_type text/plain;
set $12 "Hello";
location /ng {
# responds "2" instead of "Hello"!
# NGINX interprets '$' immediately followed by a number as the
# reference to regex captures regardless of following characters.
# https://github.com/nginx/nginx/blob/828fb94e1dbe1c433edd39147ba085c4622c99ed/src/http/ngx_http_script.c#L480-L505
return 200 "$12";
}
location /ok {
return 200 "${12}";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment