From 946be8892830e4b27e23e27f7afd0ecd4bfbbd2b Mon Sep 17 00:00:00 2001 From: cruizba Date: Fri, 16 Jun 2023 13:49:31 +0200 Subject: [PATCH] deployment: separated rules for dashboard/ and inspector/ in openvidu-proxy To fix a rule in OpenVidu Enterprise to redirect `/inspector` to `/inspector/`, now dashboard and inspector rules are separated to have different configurations depending on the OpenVidu Edition PRO or Enterprise --- .../global/enterprise-ha/common_api_enterprise.conf | 2 ++ .../dashboard_inspector_rules_enterprise.conf | 13 +++++++++++++ .../global/pro/common_api_pro.conf | 13 +------------ .../global/pro/dashboard_inspector_rules_pro.conf | 12 ++++++++++++ openvidu-server/docker/openvidu-proxy/entrypoint.sh | 11 ++++++++++- 5 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/enterprise-ha/dashboard_inspector_rules_enterprise.conf create mode 100644 openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/pro/dashboard_inspector_rules_pro.conf diff --git a/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/enterprise-ha/common_api_enterprise.conf b/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/enterprise-ha/common_api_enterprise.conf index 5b1e9ad3..98df36cc 100644 --- a/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/enterprise-ha/common_api_enterprise.conf +++ b/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/enterprise-ha/common_api_enterprise.conf @@ -1,6 +1,8 @@ ################################# # Common rules Enterprise # ################################# + {dashboard_inspector_rules_enterprise} + location /minio/ { {rules_access_dashboard} deny all; diff --git a/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/enterprise-ha/dashboard_inspector_rules_enterprise.conf b/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/enterprise-ha/dashboard_inspector_rules_enterprise.conf new file mode 100644 index 00000000..fc2c62e0 --- /dev/null +++ b/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/enterprise-ha/dashboard_inspector_rules_enterprise.conf @@ -0,0 +1,13 @@ + location /dashboard { + {rules_access_dashboard} + deny all; + rewrite ^/dashboard/(.*)$ /$1 break; + proxy_pass http://openviduserver/; + } + + location /inspector { + {rules_access_dashboard} + deny all; + rewrite ^([^.]*[^/])$ $1/ permanent; + proxy_pass http://openviduserver; + } \ No newline at end of file diff --git a/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/pro/common_api_pro.conf b/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/pro/common_api_pro.conf index 329e48fd..98919f05 100644 --- a/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/pro/common_api_pro.conf +++ b/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/pro/common_api_pro.conf @@ -1,18 +1,7 @@ ################################# # Common rules PRO # ################################# - location /dashboard { - {rules_access_dashboard} - deny all; - rewrite ^/dashboard/(.*)$ /$1 break; - proxy_pass http://openviduserver/; - } - - location /inspector { - {rules_access_dashboard} - deny all; - proxy_pass http://openviduserver; - } + {dashboard_inspector_rules_pro} location /kibana { {rules_access_dashboard} diff --git a/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/pro/dashboard_inspector_rules_pro.conf b/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/pro/dashboard_inspector_rules_pro.conf new file mode 100644 index 00000000..0549a8bb --- /dev/null +++ b/openvidu-server/docker/openvidu-proxy/default_nginx_conf/global/pro/dashboard_inspector_rules_pro.conf @@ -0,0 +1,12 @@ + location /dashboard { + {rules_access_dashboard} + deny all; + rewrite ^/dashboard/(.*)$ /$1 break; + proxy_pass http://openviduserver/; + } + + location /inspector { + {rules_access_dashboard} + deny all; + proxy_pass http://openviduserver; + } \ No newline at end of file diff --git a/openvidu-server/docker/openvidu-proxy/entrypoint.sh b/openvidu-server/docker/openvidu-proxy/entrypoint.sh index 1b15b6bb..8acc013b 100755 --- a/openvidu-server/docker/openvidu-proxy/entrypoint.sh +++ b/openvidu-server/docker/openvidu-proxy/entrypoint.sh @@ -296,7 +296,10 @@ elif [[ "${REDIRECT_WWW}" == "false" ]]; then sed -i '/{redirect_www_ssl}/d' /etc/nginx/conf.d/* fi -if [[ "${PROXY_MODE}" == "ENTERPRISE_HA" ]]; then +if [[ "${PROXY_MODE}" == "PRO" ]]; then + # Add dashboad and inspector rules + sed -e '/{dashboard_inspector_rules_pro}/{r default_nginx_conf/global/pro/dashboard_inspector_rules_pro.conf' -e 'd}' -i /etc/nginx/conf.d/* +elif [[ "${PROXY_MODE}" == "ENTERPRISE_HA" ]]; then TEMP_FILE_UPSTREAM=$(mktemp) # Create upstream nodes @@ -318,6 +321,12 @@ if [[ "${PROXY_MODE}" == "ENTERPRISE_HA" ]]; then # Add upstream nodes to nginx config sed -e '/{enterprise_ha_nodes_upstream}/{r '"${TEMP_FILE_UPSTREAM}"'' -e 'd}' -i /etc/nginx/conf.d/* + + # Add dashboad and inspector rules + # 1. First remove pro rules + sed -i '/{dashboard_inspector_rules_pro}/d' /etc/nginx/conf.d/* + # 2. Add enterprise rules + sed -e '/{dashboard_inspector_rules_enterprise}/{r default_nginx_conf/global/enterprise-ha/dashboard_inspector_rules_enterprise.conf' -e 'd}' -i /etc/nginx/conf.d/* fi # Process main configs