| {%- from "devops_portal/map.jinja" import config with context -%} |
| {%- from "devops_portal/map.jinja" import services with context -%} |
| {%- from "devops_portal/map.jinja" import service_endpoint with context -%} |
| daemon off; |
| |
| worker_processes 1; |
| |
| error_log /dev/stderr; |
| pid /var/run/nginx/nginx.pid; |
| |
| events { |
| worker_connections 1024; |
| } |
| |
| http { |
| include /etc/nginx/mime.types; |
| |
| sendfile on; |
| |
| access_log /dev/stdout; |
| |
| server { |
| listen 0.0.0.0:8000 default_server; |
| |
| root /opt/devops-portal/; |
| |
| gzip on; |
| gzip_min_length 1000; |
| gzip_types |
| text/plain |
| text/css |
| application/json |
| application/javascript |
| application/x-javascript; |
| |
| location / { |
| if ($request_method = OPTIONS ) { |
| add_header Content-Length 0; |
| add_header Content-Type text/plain; |
| return 200; |
| } |
| try_files $uri /index.html; |
| } |
| |
| {%- for service_name in services %} |
| {%- if config.service[service_name] is defined %} |
| {%- set service = config.service[service_name] %} |
| {%- if service.enabled|default(False) and service.configure_proxy|default(False) %} |
| |
| location /api/{{ service_name }} { |
| proxy_pass {{ service_url(service.endpoint) }}; |
| } |
| {%- endif %} |
| {%- endif %} |
| {%- endfor %} |
| } |
| } |