user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

worker_rlimit_nofile 20000;

events {
    worker_connections 10000;
}


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

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

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

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;


    server {
        # additional server only used for greenlight in dev mode
        # allows it to use the BBB API without failing 
        # due to the self signed certificates
        # 
        # all other requests (e.g. /join) is then redirected
        listen 48083 http2;
        
        location /bigbluebutton/api/join {
            return 301 https://10.7.7.1$request_uri;
        }
        location /bigbluebutton/api {
            proxy_pass http://127.0.0.1:48087;
        }
        location / {
            return 301 https://10.7.7.1$request_uri;
        }
    }

}
