jdauphant / ansible-role-nginx

Ansible role to install and manage nginx configuration
655 stars 302 forks source link

'nginx_sites' semicolon escaping ignores quoted values #180

Closed milliams closed 7 years ago

milliams commented 7 years ago

If I set nginx_sites to

nginx_sites:
  my_site:
    - add_header X-XSS-Protection "1; mode=block"

it is converted in the output to

server {
   add_header X-XSS-Protection "1;
       mode=block";
}

rather than

server {
   add_header X-XSS-Protection "1; mode=block";

which, as far as I can tell is treated by nginx as simply 1.

This seems to be caused by the code in templates/site.conf.j2 which simply does a

v.replace(";",";\n ")

and ignores whether the semicolon is inside quotation marks.

jdauphant commented 7 years ago

Hello @milliams,

You can use the new notation. You can see an example in #151.

Also linked to your experience, if you have an idea to improve the documentation so people will find more easely the new notation in that case: a PR in that sense will be more than welcome :) (I have multiple ticket with the same problem like #151, #170, ...).

Best regards, Julien

milliams commented 7 years ago

I think this is all my fault for not doing a thorough enough search before jumping to the issue tracker 😄 The new notation will do the job just fine and I will have a think about how to help with documenting it to avoid you having to answer the same question over and over again.