Add common part with DevopPortal
The services definitions which are located at metadata/service/services
will be moved onto the system level, to be re-used in particular
components.
Change-Id: I227638b7a486c156578e5b0d57eb6eb4d9854a89
diff --git a/devops_portal/files/nginx.conf b/devops_portal/files/nginx.conf
new file mode 100644
index 0000000..5813f5d
--- /dev/null
+++ b/devops_portal/files/nginx.conf
@@ -0,0 +1,49 @@
+{%- from "devops_portal/map.jinja" import control with context -%}
+{%- from "devops_portal/map.jinja" import services 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:{{ control.container.container_port }} 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 / {
+ try_files $uri /index.html;
+ }
+
+{%- for service_name in services %}
+{%- set service = control.services[service_name]|default({}) %}
+{%- if service.enabled and service.configure_proxy|default(False) %}
+
+ location /api/{{ service_name }} {
+ proxy_pass {{ service.endpoint }};
+ }
+{%- endif %}
+{%- endfor %}
+ }
+}