server {
    listen ${NGINX_PORT};
    access_log   /var/log/nginx/access.cmdb.log;
    error_log    /var/log/nginx/error.cmdb.log;

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

    gzip on;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_min_length 256;
    gzip_types
        text/plain
        text/css
        text/js
        text/xml
        text/javascript
        application/javascript
        application/x-javascript
        application/json
        application/xml
        application/rss+xml
        image/svg+xml;

    root  /etc/nginx/html;
    location / {
      root   /etc/nginx/html;
      index  index.html;
      try_files $uri $uri/ /index.html;
    }
    location /api {
        proxy_pass http://${CMDB_API_HOST};
        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-Scheme $scheme;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
    location ~* \.(css|js)$ {
        access_log off;
        add_header Pragma public;
        add_header Cache-Control "public, max-age=7776000";
        #add_header Cache-Control "public,no-cache, max-age=0";
        add_header X-Asset "yes";
    }
}
