Don't use set_fact, use default instead

This commit is contained in:
nemunaire 2024-07-07 14:10:09 +02:00
parent 62766d6d9c
commit 3f23e8d766
2 changed files with 59 additions and 61 deletions

View File

@ -3,3 +3,62 @@ path: /
error_pages: error_pages:
404: /404.html 404: /404.html
rewrite: [] rewrite: []
server: |
location / {
gzip on;
gzip_types application/javascript text/javascript text/css;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Authorization "";
proxy_intercept_errors on;
chunked_transfer_encoding off;
proxy_pass https://storage_nemunaire/{{ bucket }}{{ path }}/;
if ($uri ~ (.css|.js|.jpg|.png|.webp|.ico|.woff|.woff2|.ttf)$) {
expires max;
}
error_page 404 = @rewrite_proxy;
{% for error_page in error_pages %}
{% if error_page != 404 %}
error_page {{ error_page }} {{ error_pages[error_page] }};
{% endif %}
{% endfor %}
{% for r in rewrite %}
rewrite {{ r }};
{% endfor %}
}
location ~ /$ {
rewrite ^(.*)/ $1/index.html;
}
location @rewrite_proxy {
if ($http_accept ~ "text/html") {
rewrite ^/(.*)$ /{{ bucket }}{{ path }}{% if always_root is not defined or always_root %}/$1{% endif %}/index.html break;
}
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Authorization "";
proxy_intercept_errors on;
chunked_transfer_encoding off;
proxy_pass https://storage_nemunaire;
{% for error_page in error_pages %}
error_page {{ error_page }} {{ error_pages[error_page] }};
{% endfor %}
}

View File

@ -10,66 +10,5 @@
insertafter: 'http {' insertafter: 'http {'
marker: "# {mark} ANSIBLE MANAGED BLOCK storage_nemunaire" marker: "# {mark} ANSIBLE MANAGED BLOCK storage_nemunaire"
- ansible.builtin.set_fact:
server: |
location / {
gzip on;
gzip_types application/javascript text/javascript text/css;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Authorization "";
proxy_intercept_errors on;
chunked_transfer_encoding off;
proxy_pass https://storage_nemunaire/{{ bucket }}{{ path }}/;
if ($uri ~ (.css|.js|.jpg|.png|.webp|.ico|.woff|.woff2|.ttf)$) {
expires max;
}
error_page 404 = @rewrite_proxy;
{% for error_page in error_pages %}
{% if error_page != 404 %}
error_page {{ error_page }} {{ error_pages[error_page] }};
{% endif %}
{% endfor %}
{% for r in rewrite %}
rewrite {{ r }};
{% endfor %}
}
location ~ /$ {
rewrite ^(.*)/ $1/index.html;
}
location @rewrite_proxy {
if ($http_accept ~ "text/html") {
rewrite ^/(.*)$ /{{ bucket }}{{ path }}{% if always_root is not defined or always_root %}/$1{% endif %}/index.html break;
}
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Authorization "";
proxy_intercept_errors on;
chunked_transfer_encoding off;
proxy_pass https://storage_nemunaire;
{% for error_page in error_pages %}
error_page {{ error_page }} {{ error_pages[error_page] }};
{% endfor %}
}
when: server is not defined
- ansible.builtin.include_role: - ansible.builtin.include_role:
name: re.nemunai.nginx-config-svc name: re.nemunai.nginx-config-svc