forked from ISTI-ansible-roles/ansible-roles
library/roles/nginx: Give the possibility to manage CORS inside the default virtualhost.
This commit is contained in:
parent
6fceb578a2
commit
f8cbd7ad17
|
@ -60,6 +60,8 @@ nginx_proxy_temp_file_write_size: '{{ nginx_proxy_buffer_size }}'
|
||||||
nginx_client_max_body_size: 100M
|
nginx_client_max_body_size: 100M
|
||||||
nginx_client_body_timeout: 240s
|
nginx_client_body_timeout: 240s
|
||||||
|
|
||||||
|
nginx_cors_enabled: False
|
||||||
|
nginx_cors_global: True
|
||||||
nginx_cors_limit_origin: True
|
nginx_cors_limit_origin: True
|
||||||
nginx_cors_extended_rules: False
|
nginx_cors_extended_rules: False
|
||||||
nginx_cors_acl_origin: 'http?://(localhost)'
|
nginx_cors_acl_origin: 'http?://(localhost)'
|
||||||
|
|
|
@ -66,6 +66,12 @@ server {
|
||||||
client_body_timeout {{ nginx_client_body_timeout }};
|
client_body_timeout {{ nginx_client_body_timeout }};
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if nginx_cors_enabled %}
|
||||||
|
{% if nginx_cors_global %}
|
||||||
|
include /etc/nginx/snippets/nginx-cors.conf;
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if item.additional_options is defined %}
|
{% if item.additional_options is defined %}
|
||||||
{% for add_opt in item.additional_options %}
|
{% for add_opt in item.additional_options %}
|
||||||
|
|
||||||
|
@ -92,6 +98,13 @@ server {
|
||||||
{% if item.locations is defined %}
|
{% if item.locations is defined %}
|
||||||
{% for location in item.locations %}
|
{% for location in item.locations %}
|
||||||
location {{ location.location }} {
|
location {{ location.location }} {
|
||||||
|
{% if nginx_cors_enabled %}
|
||||||
|
{% if not nginx_cors_global %}
|
||||||
|
{% if location.cors is defined and location.cors %}
|
||||||
|
include /etc/nginx/snippets/nginx-cors.conf;
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% if location.target is defined %}
|
{% if location.target is defined %}
|
||||||
proxy_pass {{ location.target }};
|
proxy_pass {{ location.target }};
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -167,6 +180,20 @@ server {
|
||||||
|
|
||||||
include /etc/nginx/snippets/nginx-server-ssl.conf;
|
include /etc/nginx/snippets/nginx-server-ssl.conf;
|
||||||
|
|
||||||
|
{% if nginx_cors_enabled %}
|
||||||
|
{% if nginx_cors_global %}
|
||||||
|
include /etc/nginx/snippets/nginx-cors.conf;
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if item.additional_options is defined %}
|
||||||
|
{% for add_opt in item.additional_options %}
|
||||||
|
|
||||||
|
{{ add_opt }};
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if item.websockets is defined and item.websockets %}
|
{% if item.websockets is defined and item.websockets %}
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection $connection_upgrade;
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
@ -185,9 +212,19 @@ server {
|
||||||
{% if item.locations is defined %}
|
{% if item.locations is defined %}
|
||||||
{% for location in item.locations %}
|
{% for location in item.locations %}
|
||||||
location {{ location.location }} {
|
location {{ location.location }} {
|
||||||
|
{% if nginx_cors_enabled %}
|
||||||
|
{% if not nginx_cors_global %}
|
||||||
|
{% if location.cors is defined and location.cors %}
|
||||||
|
include /etc/nginx/snippets/nginx-cors.conf;
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% if location.target is defined %}
|
{% if location.target is defined %}
|
||||||
proxy_pass {{ location.target }};
|
proxy_pass {{ location.target }};
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if location.extra_conf is defined %}
|
||||||
|
{{ location.extra_conf }}
|
||||||
|
{% endif %}
|
||||||
{% if location.other_opts is defined %}
|
{% if location.other_opts is defined %}
|
||||||
{% for opt in location.other_opts %}
|
{% for opt in location.other_opts %}
|
||||||
{{ opt }};
|
{{ opt }};
|
||||||
|
|
Loading…
Reference in New Issue