apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
  labels:
    app: nginx
data:
  api.json: |
    user nginx;
    worker_processes 1;

    daemon off;

    events {
      worker_connections 1024;
    }

    error_log   /var/log/nginx/error.log warn;
    pid         /var/run/nginx.pid;

    http {

      upstream api {
        server 127.0.0.1:9000;
      }
      include /etc/nginx/mime.types;
      default_type application/octet-stream;

      log_format main '$remote_addr - $remote_user [$time_local] "$request" '
      '$status $body_bytes_sent "$http_referer" '
      '"$http_user_agent" "$http_x_forwarded_for"';

      access_log /var/log/nginx/access.log main;

      sendfile on;
      #tcp_nopush on;

      keepalive_timeout 65;

      gzip on;

      server {
        listen 3000 default_server;

        root /usr/html;
        index index.html;

        location /api/ {
            proxy_pass http://api;
            proxy_redirect     off;
            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   X-Forwarded-Host $server_name;
            break;
        }

        location / {
            try_files $uri /public/index.html;
        }
        location /user {
            try_files $uri /user/index.html;
        }
        location /admin {
            try_files $uri /admin/index.html;
        }

        location /favicon.ico {
          log_not_found off;
        }
      }
    }
