diff --git a/salt/nginx/enabled.sls b/salt/nginx/enabled.sls index cf3cb1e81..f1a71238a 100644 --- a/salt/nginx/enabled.sls +++ b/salt/nginx/enabled.sls @@ -54,9 +54,9 @@ so-nginx: - /opt/so/log/nginx/:/var/log/nginx:rw - /opt/so/tmp/nginx/:/var/lib/nginx:rw - /opt/so/tmp/nginx/:/run:rw - - /nsm/elastic-fleet/so_agent-installers/:/opt/socore/html/packages - - /nsm/elastic-fleet/artifacts/:/opt/socore/html/artifacts + - /nsm/elastic-fleet/artifacts/:/opt/socore/elastic-artifacts/artifacts:ro {% if GLOBALS.is_manager %} + - /nsm/elastic-fleet/so_agent-installers/:/opt/socore/html/packages - /etc/pki/managerssl.crt:/etc/pki/nginx/server.crt:ro - /etc/pki/managerssl.key:/etc/pki/nginx/server.key:ro # ATT&CK Navigator binds diff --git a/salt/nginx/etc/nginx.conf b/salt/nginx/etc/nginx.conf index 357fc7e6d..5f9f9858d 100644 --- a/salt/nginx/etc/nginx.conf +++ b/salt/nginx/etc/nginx.conf @@ -4,6 +4,8 @@ {%- set role = grains.id.split('_') | last %} {%- set influxpass = salt['pillar.get']('secrets:influx_pass') %} {%- set influxauth = ('so:' + influxpass) | base64_encode %} +{%- set all_names = [GLOBALS.hostname, GLOBALS.url_base] + NGINXMERGED.ssl.alt_names %} +{%- set full_server_name = all_names | unique | join(' ') %} worker_processes auto; error_log /var/log/nginx/error.log; @@ -39,52 +41,31 @@ http { include /etc/nginx/conf.d/*.conf; - {%- if role in ['fleet'] %} - - server { - listen 8443; - server_name {{ GLOBALS.hostname }}; - root /opt/socore/html; - location /artifacts/ { - try_files $uri =206; - proxy_read_timeout 90; - proxy_connect_timeout 90; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Proxy ""; - proxy_set_header X-Forwarded-Proto $scheme; - } - } - - {%- endif %} - {%- if GLOBALS.is_manager %} - {%- set all_names = [GLOBALS.hostname, GLOBALS.url_base] + NGINXMERGED.ssl.alt_names %} - {%- set full_server_name = all_names | unique | join(' ') %} - server { listen 80 default_server; server_name _; return 307 https://{{ GLOBALS.url_base }}$request_uri; } - + {%- endif %} + {%- if GLOBALS.is_manager or role == 'fleet' %} server { listen 8443; + {%- if GLOBALS.is_manager %} server_name {{ full_server_name }}; - root /opt/socore/html; + {%- else %} + server_name {{ GLOBALS.hostname }}; + {%- endif %} + root /opt/socore/elastic-artifacts; location /artifacts/ { - try_files $uri =206; - proxy_read_timeout 90; - proxy_connect_timeout 90; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Proxy ""; - proxy_set_header X-Forwarded-Proto $scheme; + try_files $uri =404; + } + location / { + return 404; } } - + {%- endif %} + {%- if GLOBALS.is_manager %} server { listen 443 ssl default_server; http2 on;