2016-06-13 16:24:30 +02:00
server {
listen {{ http_port }};
2016-11-29 09:42:06 +01:00
client_max_body_size {{ nginx_client_max_body_size | default('100M') }};
2016-11-18 10:54:40 +01:00
{% if egi_image is defined and egi_image %}
# No servername into the EGI images
2017-09-12 15:32:53 +02:00
{% elif hostname is defined %}
2017-09-24 13:58:34 +02:00
server_name _;
2017-09-12 15:32:53 +02:00
{% else %}
2016-11-23 12:28:05 +01:00
server_name {{ item.servername }} {% if smartgears_nginx_serveraliases is defined %}{% for vh in smartgears_nginx_serveraliases %} {{ vh }}{% endfor %}{% endif %};
2016-11-18 10:54:40 +01:00
{% endif %}
2016-09-19 19:29:58 +02:00
{% if letsencrypt_acme_install %}
2016-10-03 18:28:15 +02:00
include /etc/nginx/snippets/letsencrypt-proxy.conf;
2016-09-19 19:29:58 +02:00
{% endif %}
access_log /var/log/nginx/{{ item.servername }}_access.log;
error_log /var/log/nginx/{{ item.servername }}_error.log;
2017-09-19 15:13:57 +02:00
root {{ item.web_document_root | default('/usr/share/nginx/html/') }};
2016-06-13 16:24:30 +02:00
2016-10-03 18:28:15 +02:00
{% if haproxy_ips is defined %}
# We are behind haproxy
{% for ip in haproxy_ips %}
set_real_ip_from {{ ip }};
{% endfor %}
real_ip_header X-Forwarded-For;
{% endif %}
2016-06-13 16:24:30 +02:00
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
2016-09-19 19:29:58 +02:00
root /usr/share/nginx/html;
2016-06-13 16:24:30 +02:00
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# don't send the nginx version number in error pages and Server header
server_tokens off;
2017-09-22 13:10:24 +02:00
{% if nginx_client_body_temp_dir is defined %}
client_body_temp_path {{ nginx_client_body_temp_dir }} 1 2;
{% endif %}
2016-06-13 16:24:30 +02:00
# Proxy stuff
2016-10-03 18:28:15 +02:00
include /etc/nginx/snippets/nginx-proxy-params.conf;
2016-10-08 12:28:08 +02:00
{% if nginx_websockets_support %}
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
{% endif %}
2016-09-19 19:29:58 +02:00
2016-10-26 20:08:28 +02:00
{% if r_connector_install is defined and r_connector_install %}
2016-09-19 19:29:58 +02:00
location /auth-sign-in {
rewrite ^/auth-sign-in http://{{ item.servername }}/r-connector/gcube/service/disconnect;
}
{% endif %}
2017-07-04 18:17:13 +02:00
location /whn-manager {
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:{{ item.http_port }}/whn-manager;
2017-07-04 18:17:13 +02:00
}
{% if not http_redirect_to_https %}
2016-09-19 19:29:58 +02:00
{% for instance in tomcat_m_instances %}
{% for context in instance.app_contexts %}
2017-07-04 18:17:13 +02:00
{% if context != "whn-manager" %}
2017-07-07 13:42:33 +02:00
{% if context != '' %}
2016-06-13 16:24:30 +02:00
location /{{ context }} {
2016-11-28 16:41:06 +01:00
{% if smartgears_nginx_cors_enabled %}
include /etc/nginx/snippets/nginx-cors.conf;
2017-07-22 15:52:20 +02:00
{% if nginx_cors_extended_rules %}
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:{{ item.http_port }};
2017-07-22 15:12:47 +02:00
{% else %}
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:{{ item.http_port }}/{{ context }};
2017-07-22 15:12:47 +02:00
{% endif %}
2017-07-22 15:52:20 +02:00
{% else %}
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:{{ item.http_port }}/{{ context }};
2017-07-22 15:52:20 +02:00
{% endif %}
2016-06-13 16:24:30 +02:00
}
2017-07-04 18:17:13 +02:00
{% endif %}
2017-07-07 13:42:33 +02:00
{% endif %}
2016-09-19 19:29:58 +02:00
{% endfor %}
{% endfor %}
2016-10-26 20:08:28 +02:00
{% if smart_executor_install is defined and smart_executor_install %}
2016-06-13 16:24:30 +02:00
location {{ smart_executor_context }} {
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:{{ smartgears_http_port }}{{ smart_executor_context }};
2017-03-16 16:34:43 +01:00
}
{% endif %}
{% if data_transfer_service_install %}
location /data-transfer-service {
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:{{ smartgears_http_port }}/data-transfer-service;
2016-06-13 16:24:30 +02:00
}
2016-09-19 19:29:58 +02:00
{% endif %}
2017-09-19 15:13:57 +02:00
{% if remote_opencpu_server is defined and remote_opencpu_server %}
location {{ opencpu_context | default('/ocpu') }} {
{% if smartgears_nginx_cors_enabled %}
include /etc/nginx/snippets/nginx-cors.conf;
{% endif %}
proxy_pass http://{{ remote_opencpu_host }}:{{ opencpu_proxy_port | default('8004') }}{{ opencpu_context | default('/ocpu') }};
}
{% endif %}
2016-10-26 20:08:28 +02:00
{% if rstudio_install_server is defined and rstudio_install_server %}
2016-09-19 19:29:58 +02:00
location / {
2016-11-28 16:41:06 +01:00
{% if smartgears_nginx_cors_enabled %}
include /etc/nginx/snippets/nginx-cors.conf;
{% endif %}
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:8787/;
2016-09-19 19:29:58 +02:00
}
{% endif %}
2017-07-20 13:49:50 +02:00
{% if smartgears_nginx_expose_tomcat_logs %}
location /gcube-logs/ {
alias {{ smartgears_instance_path }}/logs/;
autoindex on;
autoindex_localtime on;
}
{% endif %}
2016-09-19 19:29:58 +02:00
{% else %}
location / {
return 301 https://{{ item.servername }}$request_uri;
}
{% endif %}
2016-10-03 18:28:15 +02:00
2016-09-19 19:29:58 +02:00
}
2016-10-03 18:28:15 +02:00
2016-09-19 19:29:58 +02:00
{% if letsencrypt_acme_install %}
server {
listen {{ https_port }} ssl;
2016-11-29 09:42:06 +01:00
client_max_body_size {{ nginx_client_max_body_size | default('100M') }};
2016-11-18 10:54:40 +01:00
{% if egi_image is defined and egi_image %}
# No servername into the EGI images
2017-09-24 13:58:34 +02:00
{% elif hostname is defined %}
server_name _;
2016-11-18 10:54:40 +01:00
{% else %}
2016-11-23 12:28:05 +01:00
server_name {{ item.servername }} {% if smartgears_nginx_serveraliases is defined %}{% for vh in smartgears_nginx_serveraliases %} {{ vh }}{% endfor %}{% endif %};
2016-11-18 10:54:40 +01:00
{% endif %}
2016-09-19 19:29:58 +02:00
access_log /var/log/nginx/{{ item.servername }}_access_ssl.log;
error_log /var/log/nginx/{{ item.servername }}_error_ssl.log;
2017-09-19 15:13:57 +02:00
root {{ item.web_document_root | default('/usr/share/nginx/html/') }};
2016-09-19 19:29:58 +02:00
2016-10-03 18:35:07 +02:00
{% if haproxy_ips is defined %}
# We are behind haproxy
{% for ip in haproxy_ips %}
set_real_ip_from {{ ip }};
{% endfor %}
real_ip_header X-Forwarded-For;
{% endif %}
2016-10-03 18:28:15 +02:00
include /etc/nginx/snippets/nginx-server-ssl.conf;
2016-09-19 19:29:58 +02:00
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# don't send the nginx version number in error pages and Server header
server_tokens off;
2017-09-22 13:10:24 +02:00
{% if nginx_client_body_temp_dir is defined %}
client_body_temp_path {{ nginx_client_body_temp_dir }} 1 2;
{% endif %}
2016-09-19 19:29:58 +02:00
# Proxy stuff
2016-10-03 18:28:15 +02:00
include /etc/nginx/snippets/nginx-proxy-params.conf;
2016-10-08 12:28:08 +02:00
{% if nginx_websockets_support %}
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
{% endif %}
2016-10-26 20:08:28 +02:00
{% if r_connector_install is defined and r_connector_install %}
2016-09-19 19:29:58 +02:00
location /auth-sign-in {
rewrite ^/auth-sign-in http://{{ item.servername }}/r-connector/gcube/service/disconnect;
}
{% endif %}
2017-07-04 18:17:13 +02:00
location /whn-manager {
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:{{ item.http_port }}/whn-manager;
2017-07-04 18:17:13 +02:00
}
2016-09-19 19:29:58 +02:00
{% for instance in tomcat_m_instances %}
{% for context in instance.app_contexts %}
2017-07-04 18:17:13 +02:00
{% if context != "whn-manager" %}
2017-07-07 13:42:33 +02:00
{% if context != '' %}
2016-09-19 19:29:58 +02:00
location /{{ context }} {
2016-11-28 16:41:06 +01:00
{% if smartgears_nginx_cors_enabled %}
include /etc/nginx/snippets/nginx-cors.conf;
2017-07-22 15:52:20 +02:00
{% if nginx_cors_extended_rules %}
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:{{ item.http_port }};
2017-07-22 15:12:47 +02:00
{% else %}
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:{{ item.http_port }}/{{ context }};
2017-07-22 15:52:20 +02:00
{% endif %}
{% else %}
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:{{ item.http_port }}/{{ context }};
2017-07-22 15:12:47 +02:00
{% endif %}
2016-09-19 19:29:58 +02:00
}
2017-07-04 18:17:13 +02:00
{% endif %}
2017-07-07 13:42:33 +02:00
{% endif %}
2016-09-19 19:29:58 +02:00
{% endfor %}
{% endfor %}
2016-10-26 20:08:28 +02:00
{% if smart_executor_install is defined and smart_executor_install %}
2016-09-19 19:29:58 +02:00
location {{ smart_executor_context }} {
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:{{ smartgears_http_port }}{{ smart_executor_context }};
2017-03-16 16:34:43 +01:00
}
{% endif %}
{% if data_transfer_service_install %}
location /data-transfer-service {
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:{{ smartgears_http_port }}/data-transfer-service;
2016-09-19 19:29:58 +02:00
}
{% endif %}
2017-09-19 15:13:57 +02:00
{% if remote_opencpu_server is defined and remote_opencpu_server %}
location {{ opencpu_context | default('/ocpu') }} {
{% if smartgears_nginx_cors_enabled %}
include /etc/nginx/snippets/nginx-cors.conf;
{% endif %}
proxy_pass http://{{ remote_opencpu_host }}:{{ opencpu_proxy_port | default('8004') }}{{ opencpu_context | default('/ocpu') }};
}
{% endif %}
2016-10-26 20:08:28 +02:00
{% if rstudio_install_server is defined and rstudio_install_server %}
2016-09-19 19:29:58 +02:00
location / {
2016-11-28 16:41:06 +01:00
{% if smartgears_nginx_cors_enabled %}
include /etc/nginx/snippets/nginx-cors.conf;
{% endif %}
2017-09-12 15:32:53 +02:00
proxy_pass http://127.0.0.1:8787/;
2016-09-19 19:29:58 +02:00
}
{% endif %}
2016-10-03 18:28:15 +02:00
2017-07-20 13:49:50 +02:00
{% if smartgears_nginx_expose_tomcat_logs %}
location /gcube-logs/ {
2017-07-20 15:04:55 +02:00
alias {{ smartgears_instance_path }}/logs/;
2017-07-20 13:49:50 +02:00
autoindex on;
autoindex_localtime on;
}
{% endif %}
2016-06-13 16:24:30 +02:00
}
2016-09-20 12:20:20 +02:00
{% endif %}