diff --git a/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2 b/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2 index 785fea0c..1510e73d 100644 --- a/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2 +++ b/smartgears/smartgears-nginx-frontend/templates/generic-smartgears-virtualhost.j2 @@ -13,7 +13,7 @@ server { {% endif %} access_log /var/log/nginx/{{ item.servername }}_access.log; error_log /var/log/nginx/{{ item.servername }}_error.log; - root /usr/share/nginx/html/; + root {{ item.web_document_root | default('/usr/share/nginx/html/') }}; {% if haproxy_ips is defined %} # We are behind haproxy @@ -90,6 +90,14 @@ server { proxy_pass http://127.0.0.1:{{ smartgears_http_port }}/data-transfer-service; } {% endif %} + {% 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 %} {% if rstudio_install_server is defined and rstudio_install_server %} location / { {% if smartgears_nginx_cors_enabled %} @@ -128,8 +136,7 @@ server { access_log /var/log/nginx/{{ item.servername }}_access_ssl.log; error_log /var/log/nginx/{{ item.servername }}_error_ssl.log; - # This is the default for nginx on Ubuntu 14.04 - root /usr/share/nginx/html/; + root {{ item.web_document_root | default('/usr/share/nginx/html/') }}; {% if haproxy_ips is defined %} # We are behind haproxy @@ -206,6 +213,14 @@ server { proxy_pass http://127.0.0.1:{{ smartgears_http_port }}/data-transfer-service; } {% endif %} + {% 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 %} {% if rstudio_install_server is defined and rstudio_install_server %} location / { {% if smartgears_nginx_cors_enabled %} diff --git a/smartgears/smartgears/defaults/main.yml b/smartgears/smartgears/defaults/main.yml index 27822ec0..ecf68242 100644 --- a/smartgears/smartgears/defaults/main.yml +++ b/smartgears/smartgears/defaults/main.yml @@ -64,9 +64,12 @@ smartgears_tomcat_listen_address: '127.0.0.1' # The iptables rules use this http_port: '{{ smartgears_http_port }}' +# Used by nginx +smartgears_web_document_root: '/usr/share/nginx/html/' + tomcat_m_webapps_unpack: True tomcat_m_instances: - - { http_enabled: True, http_port: '{{ smartgears_http_port }}', http_address: '{{ smartgears_tomcat_listen_address }}', ajp_enabled: False, ajp_port: '8109', ajp_address: '127.0.0.1', restart_timeout: '{{ tomcat_m_restart_timeout }}', shutdown_port: '-1', java_home: '{{ jdk_java_home }}', user: '{{ smartgears_user }}', user_home: '{{ smartgears_user_home }}', user_shell: '{{ tomcat_m_default_user_shell }}', instance_path: '{{ smartgears_instance_path }}', max_threads: '{{ tomcat_m_max_threads }}', autodeploy: '{{ tomcat_m_webapps_autodeploy }}', unpack: '{{ tomcat_m_webapps_unpack }}', default_conf: True, java_opts: '{{ tomcat_m_java_opts }}', java_gc_opts: '{{ tomcat_m_java_gc_opts }}', other_java_opts: '{{ tomcat_m_other_java_opts }}', jmx_enabled: '{{ tomcat_m_jmx_enabled }}', jmx_disable_additional_ports: '{{ tomcat_m_jmx_disable_additional_ports }}', jmx_port: '{{ tomcat_m_jmx_port }}', jmx_use_ssl: '{{ tomcat_m_jmx_use_ssl }}', jmx_auth_enabled: '{{ tomcat_m_jmx_auth_enabled }}', jmx_auth_dir: '{{ tomcat_m_instances_base_path }}/{{ smartgears_http_port }}/conf', jmx_monitorpass: '{{ tomcat_m_jmx_monitorpass | default(omit) }}', jmx_controlpass: '{{ tomcat_m_jmx_controlpass | default(omit) }}', catalina_tmp_directory: '{{ smartgears_tomcat_tmp_dir }}', remote_debugging: '{{ tomcat_m_enable_remote_debugging }}', remote_debugging_port: '{{ smartgears_debugging_port }}', access_log_enabled: True, log_rotation_freq: daily, log_retain: 30, allowed_hosts: [ '0.0.0.0/0' ], app_contexts: '{{ smartgears_tomcat_contexts }}', skip_smartgears: False,smartgears_id: 1, servername: '{{ ansible_fqdn }}' } + - { http_enabled: True, http_port: '{{ smartgears_http_port }}', http_address: '{{ smartgears_tomcat_listen_address }}', ajp_enabled: False, ajp_port: '8109', ajp_address: '127.0.0.1', restart_timeout: '{{ tomcat_m_restart_timeout }}', shutdown_port: '-1', java_home: '{{ jdk_java_home }}', user: '{{ smartgears_user }}', user_home: '{{ smartgears_user_home }}', user_shell: '{{ tomcat_m_default_user_shell }}', instance_path: '{{ smartgears_instance_path }}', max_threads: '{{ tomcat_m_max_threads }}', autodeploy: '{{ tomcat_m_webapps_autodeploy }}', unpack: '{{ tomcat_m_webapps_unpack }}', default_conf: True, java_opts: '{{ tomcat_m_java_opts }}', java_gc_opts: '{{ tomcat_m_java_gc_opts }}', other_java_opts: '{{ tomcat_m_other_java_opts }}', jmx_enabled: '{{ tomcat_m_jmx_enabled }}', jmx_disable_additional_ports: '{{ tomcat_m_jmx_disable_additional_ports }}', jmx_port: '{{ tomcat_m_jmx_port }}', jmx_use_ssl: '{{ tomcat_m_jmx_use_ssl }}', jmx_auth_enabled: '{{ tomcat_m_jmx_auth_enabled }}', jmx_auth_dir: '{{ tomcat_m_instances_base_path }}/{{ smartgears_http_port }}/conf', jmx_monitorpass: '{{ tomcat_m_jmx_monitorpass | default(omit) }}', jmx_controlpass: '{{ tomcat_m_jmx_controlpass | default(omit) }}', catalina_tmp_directory: '{{ smartgears_tomcat_tmp_dir }}', remote_debugging: '{{ tomcat_m_enable_remote_debugging }}', remote_debugging_port: '{{ smartgears_debugging_port }}', access_log_enabled: True, log_rotation_freq: daily, log_retain: 30, allowed_hosts: [ '0.0.0.0/0' ], app_contexts: '{{ smartgears_tomcat_contexts }}', web_document_root: '{{ smartgears_web_document_root }}' , skip_smartgears: False, smartgears_id: 1, servername: '{{ ansible_fqdn }}' } # To enable debugging: # - Set diff --git a/smartgears/smartgears/tasks/smartgears-app.yml b/smartgears/smartgears/tasks/smartgears-app.yml index b3d6c6fd..6e3ab121 100644 --- a/smartgears/smartgears/tasks/smartgears-app.yml +++ b/smartgears/smartgears/tasks/smartgears-app.yml @@ -119,6 +119,7 @@ become_user: '{{ smartgears_user }}' shell: /usr/local/bin/get-scopes {{ gcube_admin_token | default('') }} when: gcube_admin_token is defined or smartgears_upgrade + ignore_errors: True notify: Restart smartgears tags: [ 'smartgears', 'smartgears_conf', 'tomcat' ]