worker_processes auto;
user nginx nginx;
events {
  worker_connections  4096;
}

http {
  include /etc/nginx/mime.types;
  default_type application/octet-stream;

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

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

  sendfile on;
  keepalive_timeout 65;
  client_body_buffer_size 128k;
  client_header_buffer_size 2k;

  gzip on;
  gzip_types applicaiton/javascript text/css image/png image/jpeg image/gif;

  upstream backend {
      server monkeycode-server:8888;
  }

  server {
    listen 80;
    listen [::]:80;
    server_name _;

    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-Proto $scheme;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

    location /api {
            proxy_pass http://backend;
    }

    location /v1 {
            proxy_pass http://backend;
    }
  }
}