Comments (9)
i tried copying and modifying the similiar logic in the other other templates
{% if v != "" %}{{ v.replace(";",";\n ").replace(" {"," {\n ").replace(" }"," \n }\n") }}{% if v.find('{') == -1%};
but that code looks like it would have problems with semicolons within strings , as there's no code to check of the semicolin is within a quoted string and thus should ignore it.
from ansible-role-nginx.
Hi @jrobeson ,
Sorry for the late response on that, you can do something like that :
bar:
- |
map $scheme $hsts_header {
https 'max-age=10886400; includeSubDomains;'
}
In yaml "|" is a string where new lines are keeped.
Normaly it's works but produce ugly conf.
You can test this commit that produce good conf input :
362b995
It's you see not problem with the commit, I will merge it to master.
What do you thinks ?
Thanks in advance for you anwser
from ansible-role-nginx.
I close the ticket it's now supported in the version 1.2 :
- |
map $scheme $hsts_header {
https 'max-age=10886400; includeSubDomains;'
}
Thanks for your help @jrobeson
from ansible-role-nginx.
Sorry to comment on this old issue, but was just wondering why the v.replace(";",";\n ")
part is needed. A lot of http headers can have semicolons in them.
Just as an example, after updating some things in my code base, my Content-Security-Policy started having problems and I tracked it down to the extra \n inserted in the semicolons in it.
I removed the replace(";",";\n ")
in my local copy, but am wondering what it is needed for.
from ansible-role-nginx.
@chanon It's for that you have a second notation: you can see a exemple of the new notation in my last message.
Change apply to each notation
Old notation:
{% if v != "" %}{{ v.replace(";",";\n ").replace(" {"," {\n ").replace(" }"," \n }\n") }}{% if v.find('{') == -1%}; {% endif %}{% endif %}
New notation:
{{v.replace("\n","\n ")}}
from ansible-role-nginx.
Hey @chanon, did you get your answer in my last message ?
Also replace(";",";\n ")
was introduced to have good output file.
from ansible-role-nginx.
I don't think this issue is resolved? The /templates/nginx.conf.j2
file http block is
http {
include {{ nginx_conf_dir }}/mime.types;
default_type application/octet-stream;
{% for v in nginx_http_params %}
{{ v }};
{% endfor %}
include {{ nginx_conf_dir }}/conf.d/*.conf;
include {{ nginx_conf_dir }}/sites-enabled/*;
}
Which adds a semicolon to every http parameter - including the map block which will then fail as it shouldn't have a semicolon. @jrobeson seems to have suggested replacing it with the block from site.conf.j2, which I did, and it now works (unsure if it breaks in other scenarios):
http {
include {{ nginx_conf_dir }}/mime.types;
default_type application/octet-stream;
{% for v in nginx_http_params %}
{% if v.find('\n') != -1 %}
{{v.replace("\n","\n ")}}
{% else %}
{% if v != "" %}{{ v.replace(";",";\n ").replace(" {"," {\n ").replace(" }"," \n }\n") }}{% if v.find('{') == -1%};
{% endif %}{% endif %}{% endif %}
{% endfor %}
include {{ nginx_conf_dir }}/conf.d/*.conf;
include {{ nginx_conf_dir }}/sites-enabled/*;
}
from ansible-role-nginx.
Hello @ElRoberto538 ,
It was already propose #141 .
We haven't merge it to promote "nginx_configs" variable instead.
from ansible-role-nginx.
@jdauphant Ah, right... Thanks for that, I don't know how I missed that. At least now there's a link for others to hopefully not make the same mistake as me!
from ansible-role-nginx.
Related Issues (20)
- Add installation from sources HOT 1
- remove a site is not taken in consideration HOT 2
- Ansible error HOT 1
- Change nginx user HOT 4
- disable default config HOT 5
- Error in handlers/main.yml HOT 1
- issue when adding header parameter with ";" HOT 1
- Does this role need run as root? HOT 1
- amplify.api_key variable does not exist HOT 1
- add_header X-XSS-Protection is causing problems HOT 2
- Nginx didn't start on install
- v2.16 missing on https://galaxy.ansible.com/jdauphant/nginx HOT 1
- Warning, Duplicate When Key HOT 5
- Allow for no default config to be generated HOT 3
- Configuring modules is currently limited to Centos/RHEL only HOT 1
- Missing mime.types file plus /etc/mime.types idea HOT 2
- Adhere to ansible-lint rules HOT 2
- Travis job is still on python 2.7 HOT 2
- Debian 12 (python3) support
- version > v2.21.2 are not avaiable via ansible-galaxy install command
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-role-nginx.