upstream backend_account {
  hash $proxy_add_x_forwarded_for;
  server 172.17.0.3:9881;
}

upstream backend_biz_s0 {
  hash $proxy_add_x_forwarded_for;
  server 172.17.0.2:8881;
}


server {
  listen 80;
  server_name _;
  client_max_body_size 2000M;

  proxy_connect_timeout 1m;
  proxy_send_timeout 30m;
  proxy_read_timeout 30m;
  proxy_set_header Connection '';
  proxy_http_version 1.1;
  chunked_transfer_encoding off;
  proxy_buffering off;
  proxy_cache off;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_set_header X-Forwarded-Server $host;
  add_header 'Access-Control-Allow-Origin' * always;
  add_header 'Access-Control-Allow-Credentials' 'true' always;
  add_header 'Access-Control-Allow-Methods' 'GET,POST,DELETE,PUT,HEAD,OPTIONS' always;
  add_header 'Access-Control-Allow-Headers' 'DNT,token,Authorization,Accept,Origin,Keep-Alive,User-Agent,X-Mx-ReqToken,X-Data-Type,X-Auth-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  add_header 'Access-Control-Expose-Headers' 'Set-Cookie,Content-Disposition,Content-Range,RequestId,Date' always;

  location / {
    proxy_pass http://backend_account$request_uri;
    access_log /var/log/nginx/informat_next_account_access_web.log;
  }

  location ^~ /web0/ {
    access_log /var/log/nginx/informat_next_biz_api_web.log;
    if ($request_method = 'OPTIONS') {
       return 204;
    }
    proxy_pass http://backend_biz_s0/web/;
  }

  location ^~ /account/ {
    access_log /var/log/nginx/informat_next_account_api_web.log;
    if ($request_method = 'OPTIONS') {
       return 204;
    }
    proxy_pass http://backend_account$request_uri;
  }

  location /nginx_status {
    stub_status on;
    access_log off;
    allow 127.0.0.1;
    deny all;
  }
}


server {
  listen 19881;
  server_name localhost;
  client_max_body_size 2000M;

  proxy_connect_timeout 1m;
  proxy_send_timeout 30m;
  proxy_read_timeout 30m;
  proxy_set_header Connection '';
  proxy_http_version 1.1;
  chunked_transfer_encoding off;
  proxy_buffering off;
  proxy_cache off;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_set_header X-Forwarded-Server $host;
  add_header 'Access-Control-Allow-Origin' * always;
  add_header 'Access-Control-Allow-Credentials' 'true' always;
  add_header 'Access-Control-Allow-Methods' 'GET,POST,DELETE,PUT,HEAD,OPTIONS' always;
  add_header 'Access-Control-Allow-Headers' 'DNT,token,Authorization,Accept,Origin,Keep-Alive,User-Agent,X-Mx-ReqToken,X-Data-Type,X-Auth-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
  add_header 'Access-Control-Expose-Headers' 'Set-Cookie,Content-Disposition,Content-Range,RequestId,Date' always;

  location / {
    proxy_pass http://backend_account$request_uri;
    access_log /var/log/nginx/informat_next_account_access_web.log;
  }

  location ^~ /web0/ {
    access_log /var/log/nginx/informat_next_biz_api_web.log;
    if ($request_method = 'OPTIONS') {
       return 204;
    }
    proxy_pass http://backend_biz_s0/web/;
  }

  location ^~ /account/ {
    access_log /var/log/nginx/informat_next_account_api_web.log;
    if ($request_method = 'OPTIONS') {
       return 204;
    }
    proxy_pass http://backend_account$request_uri;
  }
}
