add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";

upstream openvidu-basic-videoconference {
    server url_ov_basic_videoconference;
}

upstream openvidu-basic-webinar {
    server url_ov_basic_webinar;
}

upstream openvidu-classroom {
    server url_ov_classroom;
}

upstream openvidu-getaroom {
    server url_ov_getaroom;
}

upstream openvidu-call {
    server url_ov_call;
}

server {
    listen 80;
    server_name _;

    root /var/www/html;

    proxy_set_header Host $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;
    proxy_set_header X-Forwarded-Proto https;
    proxy_headers_hash_bucket_size 512;
    proxy_redirect off;

    # Websockets
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    
    location /basic-videoconference {
        rewrite /basic-videoconference(.*) /$1 break;
        proxy_pass http://openvidu-basic-videoconference;
    }

    location /basic-webinar {
        rewrite /basic-webinar(.*) /$1 break;
        proxy_pass https://openvidu-basic-webinar;
    }

    location /getaroom {
        rewrite /getaroom(.*) /$1 break;
        proxy_pass http://openvidu-getaroom;
    }

    location /classroom {
        rewrite /classroom(.*) $1 break;
        proxy_pass https://openvidu-classroom;
    }

    location /openvidu-call {
        rewrite /openvidu-call(.*) $1 break;
        proxy_pass http://openvidu-call;   
    }
}
