server {
  # proxied from HAProxy
  listen 48082 http2 proxy_protocol;
  listen 48081 proxy_protocol;

  # optional ports for other reverse proxies
  listen 48087 default_server;
  listen [::]:48087 default_server;

  server_name _;
  access_log /dev/stdout;
  absolute_redirect off;
  root /www/;
  
  # This variable is used instead of $scheme by bigbluebutton nginx include
  # files, so $scheme can be overridden in reverse-proxy configurations.
  set $real_scheme $scheme;

  # opt-out of google's floc tracking
  # https://www.eff.org/deeplinks/2021/03/googles-floc-terrible-idea
  add_header Permissions-Policy "interest-cohort=()";


  # Include specific rules for record and playback
  include /etc/nginx/bbb/*.nginx;

  # redirect old greenlight v2 room links
  location ~ "/b/([a-z0-9\-]+)" {
    return 302 /rooms/$1;
  }

  # serve default.pdf from /www/
  location = /default.pdf {
    try_files $uri =404;
  }

  location / {
    proxy_pass          http://greenlight:3000;
    proxy_set_header    Host              $host;
    proxy_set_header    X-Forwarded-For   "127.0.0.1";
    proxy_set_header    X-Forwarded-Proto $scheme;
    proxy_set_header    X-Forwarded-Ssl on;
    proxy_http_version  1.1;
    client_max_body_size 1000m;
  }

  location /cable {
    proxy_pass          http://greenlight:3000;
    proxy_set_header    Host              $host;
    proxy_set_header    X-Forwarded-For   "127.0.0.1";
    proxy_set_header    X-Forwarded-Proto $scheme;
    proxy_set_header    X-Forwarded-Ssl on;
    proxy_set_header    Upgrade           $http_upgrade;
    proxy_set_header    Connection        "Upgrade";
    proxy_http_version  1.1;
    proxy_read_timeout  6h;
    proxy_send_timeout  6h;
    client_body_timeout 6h;
    send_timeout        6h;
  }
}

upstream hasura {
    least_conn;
    server bbb-graphql-server:8085;
    # you might want to add more bbb-graphql-server@ instances to balance the
    # load to multiple bbb-graphql-server instances. Execute 
    # `systemctl enable --now bbb-graphql-server@8086` and uncomment the
    # following line:
    # server 127.0.0.1:8086;
}
server {
    listen 10.7.7.1:8185;
    listen 127.0.0.1:8185;

    root /var/www/html;

    location / {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;

	    proxy_pass http://hasura;
    }
}