server {
  listen 80;
  server_name _;

  gzip on;
  gzip_min_length 1k;
  gzip_buffers 4 16k;
  gzip_http_version 1.0;
  gzip_comp_level 4;
  gzip_types text/plain application/x-javascript text/css application/xml application/javascript;
  gzip_vary on;
  
  add_header 'Access-Control-Allow-Origin' '*';
  add_header 'Access-Control-Allow-Credentials' 'true';
  
  location / {
    expires -1;
    if ($request_filename ~ \.(css|js|png|gif|jpg|jpeg|bmp|ico)$) {
      expires 30d;
    }
    set_by_lua $rootPath '
      local pre = "/home/quant_group/";
      local sys = os.getenv("SYSTEM_NAME");
      return pre..sys.."/dist"
    ';
    root $rootPath;
    try_files $uri $uri/ /index.html?$query_string;
  }
  location /pdf {
    if ($host ~* contract-op-(\w+).([\w\.]+)){
        set $domain $1;
        set $tier $2;
    }
    rewrite  ^/pdf/(.*)$ /$1 break;
    proxy_pass  https://pdf-$domain.$tier;
  }
}