diff --git a/smartgears/smartgears-nginx-frontend/defaults/main.yml b/smartgears/smartgears-nginx-frontend/defaults/main.yml index 95fb2170..c5fd6f87 100644 --- a/smartgears/smartgears-nginx-frontend/defaults/main.yml +++ b/smartgears/smartgears-nginx-frontend/defaults/main.yml @@ -4,3 +4,5 @@ http_redirect_to_https: False letsencrypt_acme_install: False smartgears_install_generic_virthost: True #smartgears_nginx_serveraliases: +smartgears_nginx_cors_enabled: False +nginx_cors_acl_origin: '' diff --git a/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2 b/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2 index 97b89556..8fd5a5cc 100644 --- a/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2 +++ b/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2 @@ -59,22 +59,34 @@ server { {% for instance in tomcat_m_instances %} {% for context in instance.app_contexts %} location /{{ context }} { + {% if smartgears_nginx_cors_enabled %} + include /etc/nginx/snippets/nginx-cors.conf; + {% endif %} proxy_pass http://localhost:{{ item.http_port }}/{{ context }}; } {% endfor %} {% endfor %} {% if smart_executor_install is defined and smart_executor_install %} location {{ smart_executor_context }} { + {% if smartgears_nginx_cors_enabled %} + include /etc/nginx/snippets/nginx-cors.conf; + {% endif %} proxy_pass http://localhost:{{ item.http_port }}{{ smart_executor_context }}; } {% endif %} {% if rstudio_install_server is defined and rstudio_install_server %} location / { + {% if smartgears_nginx_cors_enabled %} + include /etc/nginx/snippets/nginx-cors.conf; + {% endif %} proxy_pass http://localhost:8787/; } {% endif %} {% else %} location / { + {% if smartgears_nginx_cors_enabled %} + include /etc/nginx/snippets/nginx-cors.conf; + {% endif %} return 301 https://{{ item.servername }}$request_uri; } {% endif %} @@ -143,17 +155,26 @@ server { {% for instance in tomcat_m_instances %} {% for context in instance.app_contexts %} location /{{ context }} { + {% if smartgears_nginx_cors_enabled %} + include /etc/nginx/snippets/nginx-cors.conf; + {% endif %} proxy_pass http://localhost:{{ item.http_port }}/{{ context }}; } {% endfor %} {% endfor %} {% if smart_executor_install is defined and smart_executor_install %} location {{ smart_executor_context }} { + {% if smartgears_nginx_cors_enabled %} + include /etc/nginx/snippets/nginx-cors.conf; + {% endif %} proxy_pass http://localhost:{{ item.http_port }}{{ smart_executor_context }}; } {% endif %} {% if rstudio_install_server is defined and rstudio_install_server %} location / { + {% if smartgears_nginx_cors_enabled %} + include /etc/nginx/snippets/nginx-cors.conf; + {% endif %} proxy_pass http://localhost:8787/; } {% endif %}