Ilya Kharin | 9954eaf | 2017-03-06 15:21:07 +0400 | [diff] [blame] | 1 | {%- from "devops_portal/map.jinja" import control with context -%} |
| 2 | {%- from "devops_portal/map.jinja" import services with context -%} |
| 3 | daemon off; |
| 4 | |
| 5 | worker_processes 1; |
| 6 | |
| 7 | error_log /dev/stderr; |
| 8 | pid /var/run/nginx/nginx.pid; |
| 9 | |
| 10 | events { |
| 11 | worker_connections 1024; |
| 12 | } |
| 13 | |
| 14 | http { |
| 15 | include /etc/nginx/mime.types; |
| 16 | |
| 17 | sendfile on; |
| 18 | |
| 19 | access_log /dev/stdout; |
| 20 | |
| 21 | server { |
Ilya Kharin | c27499c | 2017-03-14 16:52:59 +0400 | [diff] [blame] | 22 | listen 0.0.0.0:8000 default_server; |
Ilya Kharin | 9954eaf | 2017-03-06 15:21:07 +0400 | [diff] [blame] | 23 | |
| 24 | root /opt/devops-portal/; |
| 25 | |
| 26 | gzip on; |
| 27 | gzip_min_length 1000; |
| 28 | gzip_types |
| 29 | text/plain |
| 30 | text/css |
| 31 | application/json |
| 32 | application/javascript |
| 33 | application/x-javascript; |
| 34 | |
| 35 | location / { |
| 36 | try_files $uri /index.html; |
| 37 | } |
| 38 | |
| 39 | {%- for service_name in services %} |
Ilya Kharin | d80a6f6 | 2017-03-15 12:40:36 +0400 | [diff] [blame] | 40 | {%- if control.services[service_name] is defined %} |
| 41 | {%- set service = control.services[service_name] %} |
| 42 | {%- if service.enabled|default(False) and service.configure_proxy|default(False) %} |
Ilya Kharin | 9954eaf | 2017-03-06 15:21:07 +0400 | [diff] [blame] | 43 | |
| 44 | location /api/{{ service_name }} { |
| 45 | proxy_pass {{ service.endpoint }}; |
| 46 | } |
| 47 | {%- endif %} |
Ilya Kharin | d80a6f6 | 2017-03-15 12:40:36 +0400 | [diff] [blame] | 48 | {%- endif %} |
Ilya Kharin | 9954eaf | 2017-03-06 15:21:07 +0400 | [diff] [blame] | 49 | {%- endfor %} |
| 50 | } |
| 51 | } |