apiVersion: v1
kind: ConfigMap
metadata:
  name: api-nginx-cm
data:
  default.conf: |
    server {
      listen 80;
      server_name _;
      root /api/public;

      add_header 'Access-Control-Allow-Origin' "*" always;
      add_header 'Access-Control-Allow-Credentials' 'true' always;
      add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
      add_header 'Access-Control-Allow-Headers' 'X-Total-Count,Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
      add_header 'Access-Control-Expose-Headers' 'X-Total-Count' always;

      if ($request_method = OPTIONS ) {
        return 204;
      }

      location / {
        index index.html index.htm index.php;
        try_files $uri $uri/ /index.php?$args;
      }

      location ~ \.php$ {
        try_files $uri /index.php =404;
        # Each fastcgi application have different port
        fastcgi_pass  localhost:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
      }
    }

