server {
  listen 80;
  server_name _;

  root /usr/share/nginx/html;
  index index.html;

  location = /ethan {
    return 301 $scheme://$http_host/ethan/;
  }

  location /ethan/ {
    try_files $uri $uri/ /ethan/index.html;
  }

  location = /brice {
    return 301 $scheme://$http_host/brice/;
  }

  location /brice/ {
    try_files $uri $uri/ /brice/index.html;
  }

  location /auth/ {
    proxy_http_version 1.1;
    proxy_pass http://keycloak:8080/auth/;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  location /api/ {
    proxy_http_version 1.1;
    proxy_pass http://auth:8080/api/;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  location / {
    try_files $uri $uri/ /index.html;
  }
}
