|
| 1 | +map $http_upgrade $connection_upgrade { |
| 2 | + default upgrade; |
| 3 | + '' close; |
| 4 | +} |
| 5 | + |
| 6 | +{% if dehydrated | cert_exists(kibana.domain) and kibana.use_dehydrated %} |
1 | 7 | server {
|
2 |
| - {% if dehydrated|cert_exists(kibana.domain) and kibana.use_dehydrated %} |
3 |
| - listen 0.0.0.0:443 ssl http2; |
4 |
| - listen [::]:443 ssl http2; |
5 |
| - {% else %} |
6 |
| - listen 0.0.0.0:80; |
7 |
| - listen [::]:80; |
8 |
| - {% endif %} |
| 8 | + listen 0.0.0.0:80; |
| 9 | + listen [::]:80; |
| 10 | + {% if ansible_local.proserver|default(none) and ansible_local.proserver.routing.with_gate64 -%} |
| 11 | + listen [::1]:87 proxy_protocol; |
| 12 | + {%- endif %} |
| 13 | + |
| 14 | + server_name {{ kibana.domain }}; |
| 15 | + |
| 16 | + root /var/null; |
| 17 | + |
| 18 | + location / { |
| 19 | + return 301 https://$host$request_uri; |
| 20 | + } |
| 21 | + |
| 22 | + include {{ nginx.prefix.config }}/include/letsencrypt.conf; |
| 23 | +} |
| 24 | + |
| 25 | +server { |
| 26 | + listen 0.0.0.0:443 ssl http2; |
| 27 | + listen [::]:443 ssl http2; |
9 | 28 |
|
10 |
| - server_name {{ kibana.domain }}; |
| 29 | + server_name {{ kibana.domain }}; |
| 30 | + |
| 31 | + client_max_body_size 100M; |
11 | 32 |
|
12 |
| - include {{ nginx.prefix.config }}/include/security_headers.conf; |
| 33 | + include {{ nginx.prefix.config }}/include/security_headers.conf; |
13 | 34 |
|
| 35 | + {% if kibana.oauth2_proxy %} |
| 36 | + location /proserver/iap { |
| 37 | + proxy_pass http://[::1]:{{ oauth2_proxy.config[kibana.oauth2_proxy].http_address.split(":")[-1] }}; |
| 38 | + proxy_set_header Host $host; |
| 39 | + proxy_set_header X-Real-IP $remote_addr; |
| 40 | + proxy_set_header X-Scheme $scheme; |
| 41 | + proxy_set_header X-Auth-Request-Redirect $request_uri; |
| 42 | + } |
| 43 | + |
| 44 | + location = /proserver/iap/auth { |
| 45 | + proxy_pass http://[::1]:{{ oauth2_proxy.config[kibana.oauth2_proxy].http_address.split(":")[-1] }}; |
| 46 | + proxy_set_header Host $host; |
| 47 | + proxy_set_header X-Real-IP $remote_addr; |
| 48 | + proxy_set_header X-Scheme $scheme; |
| 49 | + proxy_set_header Content-Length ""; |
| 50 | + proxy_pass_request_body off; |
| 51 | + } |
| 52 | + {% endif %} |
| 53 | + |
| 54 | + location / { |
14 | 55 | {% if kibana.oauth2_proxy %}
|
15 |
| - location /proserver/iap { |
16 |
| - proxy_pass http://[::1]:{{ oauth2_proxy.config[kibana.oauth2_proxy].http_address.split(":")[-1] }}; |
17 |
| - proxy_set_header Host $host; |
18 |
| - proxy_set_header X-Real-IP $remote_addr; |
19 |
| - proxy_set_header X-Scheme $scheme; |
20 |
| - proxy_set_header X-Auth-Request-Redirect $request_uri; |
21 |
| - } |
22 |
| - |
23 |
| - location = /proserver/iap/auth { |
24 |
| - proxy_pass http://[::1]:{{ oauth2_proxy.config[kibana.oauth2_proxy].http_address.split(":")[-1] }}; |
25 |
| - proxy_set_header Host $host; |
26 |
| - proxy_set_header X-Real-IP $remote_addr; |
27 |
| - proxy_set_header X-Scheme $scheme; |
28 |
| - proxy_set_header Content-Length ""; |
29 |
| - proxy_pass_request_body off; |
30 |
| - } |
| 56 | + auth_request /proserver/iap/auth; |
| 57 | + error_page 401 = /proserver/iap/sign_in; |
| 58 | + auth_request_set $auth_cookie $upstream_http_set_cookie; |
| 59 | + add_header Set-Cookie $auth_cookie; |
31 | 60 | {% endif %}
|
32 | 61 |
|
33 |
| - location / { |
34 |
| - {% if kibana.oauth2_proxy %} |
35 |
| - auth_request /proserver/iap/auth; |
36 |
| - error_page 401 = /proserver/iap/sign_in; |
37 |
| - auth_request_set $auth_cookie $upstream_http_set_cookie; |
38 |
| - add_header Set-Cookie $auth_cookie; |
39 |
| - {% endif %} |
40 |
| - |
41 |
| - proxy_pass http://127.0.0.1:5601; |
42 |
| - proxy_http_version 1.1; |
43 |
| - proxy_set_header Upgrade $http_upgrade; |
44 |
| - proxy_set_header Connection "upgrade"; |
45 |
| - proxy_set_header Host $host; |
46 |
| - proxy_cache_bypass $http_upgrade; |
47 |
| - } |
48 |
| - |
49 |
| - {% if dehydrated|cert_exists(kibana.domain) and kibana.use_dehydrated -%} |
50 |
| - ############################################################################ |
51 |
| - # HTTPS |
52 |
| - ############################################################################ |
53 |
| - ssl_certificate {{ dehydrated|cert_fullchain(kibana.domain) }}; |
54 |
| - ssl_certificate_key {{ dehydrated|cert_privkey(kibana.domain) }}; |
55 |
| - ssl_trusted_certificate {{ dehydrated|cert_chain(kibana.domain) }}; |
56 |
| - include {{ nginx.prefix.config }}/include/https_params.conf; |
57 |
| - {% endif %} |
| 62 | + proxy_pass http://127.0.0.1:5601; |
| 63 | + proxy_http_version 1.1; |
| 64 | + proxy_set_header Upgrade $http_upgrade; |
| 65 | + proxy_set_header Connection "upgrade"; |
| 66 | + proxy_set_header Host $host; |
| 67 | + proxy_cache_bypass $http_upgrade; |
| 68 | + } |
| 69 | + |
| 70 | + ssl_certificate {{ dehydrated|cert_fullchain(kibana.domain) }}; |
| 71 | + ssl_certificate_key {{ dehydrated|cert_privkey(kibana.domain) }}; |
| 72 | + ssl_trusted_certificate {{ dehydrated|cert_chain(kibana.domain) }}; |
| 73 | + include {{ nginx.prefix.config }}/include/https_params.conf; |
| 74 | +} |
| 75 | +{% else %} |
| 76 | + |
| 77 | +server { |
| 78 | + listen 0.0.0.0:80; |
| 79 | + listen [::]:80; |
| 80 | + |
| 81 | + server_name {{ kibana.domain }}; |
| 82 | + |
| 83 | + location / { |
| 84 | + proxy_pass http://127.0.0.1:5601; |
| 85 | + proxy_http_version 1.1; |
| 86 | + proxy_set_header Upgrade $http_upgrade; |
| 87 | + proxy_set_header Connection "upgrade"; |
| 88 | + proxy_set_header Host $host; |
| 89 | + proxy_cache_bypass $http_upgrade; |
| 90 | + } |
58 | 91 | }
|
| 92 | +{% endif %} |
0 commit comments