events {
  worker_connections 768;
}

http {
  server {
    listen 80;
    access_log off; # this is handled by the container
    error_log off;

    server_name my.gmus;

    location / {
      proxy_pass http://gmus-backend:3000;
      proxy_set_header Host $http_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 /pubsub {
      proxy_pass http://gmus-backend:3000/pubsub;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_set_header Host $host;
    }
  }

  server {
    listen 443 ssl http2;
    access_log off; # this is handled by the container
    error_log off;

    # self-signed (development mode)
    ssl_certificate /etc/certificates/cert.pem;
    ssl_certificate_key /etc/certificates/key.pem;

    server_name my.budget;

    location / {
      proxy_pass http://gmus-backend:3000;
      proxy_set_header Host $http_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 /pubsub {
      proxy_pass http://gmus-backend:3000/pubsub;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_set_header Host $host;
    }
  }
}
