worker_processes 1;

events { worker_connections 1024; }

http {
  upstream springcontainer {
    server spring:8080 max_fails=5 fail_timeout=30s;
  }

  server {
    listen 80;
    error_log /dev/stdout debug;
    access_log /dev/stdout;

    location / {
      return 302 $scheme://$http_host/login;
    }
    
    location = /login {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host $http_host;
      proxy_pass http://springcontainer;
      proxy_redirect off;
    }
    
    location = /movies {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host $http_host;
      proxy_pass http://springcontainer;
      proxy_redirect off;
    }
  }
}

