You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by zh...@apache.org on 2024/08/23 08:13:03 UTC

(incubator-devlake) branch feat-configui-nginx-to-add-cloud-proxy created (now cdbedfa0f)

This is an automated email from the ASF dual-hosted git repository.

zhangning pushed a change to branch feat-configui-nginx-to-add-cloud-proxy
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


      at cdbedfa0f add cloud api proxy

This branch includes the following new commits:

     new cdbedfa0f add cloud api proxy

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(incubator-devlake) 01/01: add cloud api proxy

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zhangning pushed a commit to branch feat-configui-nginx-to-add-cloud-proxy
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit cdbedfa0fa1d466a8b441acca6ac337f040569c3
Author: ZhangNing10 <ni...@merico.dev>
AuthorDate: Fri Aug 23 16:12:47 2024 +0800

    add cloud api proxy
---
 config-ui/nginx.conf | 26 ++++++++++++++++++++++++++
 config-ui/nginx.sh   |  2 +-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/config-ui/nginx.conf b/config-ui/nginx.conf
index 959d8bff8..7d810010a 100644
--- a/config-ui/nginx.conf
+++ b/config-ui/nginx.conf
@@ -22,9 +22,13 @@ ${SERVER_CONF}
     resolver ${DNS} valid=${DNS_VALID};
     resolver_timeout 3s;
     set $target "${DEVLAKE_ENDPOINT}";
+
+    #https://serverfault.com/questions/459369/disabling-url-decoding-in-nginx-proxy
     rewrite ^ $request_uri;
     rewrite ^/api/(.*) $1 break;
+    # If the second rewrite rule doesn't match, return 400
     return 400;
+
     proxy_send_timeout 60s;
     proxy_read_timeout 60s;
     proxy_pass ${DEVLAKE_ENDPOINT_PROTO}://$target/$uri;
@@ -45,6 +49,28 @@ ${SERVER_CONF}
     proxy_set_header   "Connection" "";
   }
 
+  location /cloud-api/ {
+    resolver ${DNS} valid=${DNS_VALID};
+    resolver_timeout 3s;
+
+    set $target "${DEVLAKE_CLOUD_API}";
+    if ($target = "") {
+      return 503;
+    }
+
+    #https://serverfault.com/questions/459369/disabling-url-decoding-in-nginx-proxy
+    rewrite ^ $request_uri;
+    rewrite ^/cloud-api/(.*) $1 break;
+    # If the second rewrite rule doesn't match, return 400
+    return 400;
+
+    proxy_send_timeout 60s;
+    proxy_read_timeout 60s;
+    proxy_pass $target/$uri;
+    proxy_http_version 1.1;
+    proxy_set_header   "Connection" "";
+  }
+
   location /grafana/ {
     auth_basic off;
     set $external "${USE_EXTERNAL_GRAFANA}";
diff --git a/config-ui/nginx.sh b/config-ui/nginx.sh
index 3e216b451..e35587a64 100755
--- a/config-ui/nginx.sh
+++ b/config-ui/nginx.sh
@@ -45,7 +45,7 @@ export DNS=$(awk 'BEGIN{ORS=" "} $1=="nameserver" {if ($2 ~ ":") {print "["$2"]"
 export DNS_VALID=${DNS_VALID:-300s}
 export DEVLAKE_ENDPOINT_PROTO=${DEVLAKE_ENDPOINT_PROTO:-http}
 export GRAFANA_ENDPOINT_PROTO=${GRAFANA_ENDPOINT_PROTO:-http}
-envsubst '${LISTENER} ${DEVLAKE_ENDPOINT} ${DEVLAKE_ENDPOINT_PROTO} ${GRAFANA_ENDPOINT} ${GRAFANA_ENDPOINT_PROTO} ${USE_EXTERNAL_GRAFANA} ${SERVER_CONF} ${DNS} ${DNS_VALID}' \
+envsubst '${LISTENER} ${DEVLAKE_ENDPOINT} ${DEVLAKE_ENDPOINT_PROTO} ${DEVLAKE_CLOUD_API} ${GRAFANA_ENDPOINT} ${GRAFANA_ENDPOINT_PROTO} ${USE_EXTERNAL_GRAFANA} ${SERVER_CONF} ${DNS} ${DNS_VALID}' \
     < /etc/nginx/conf.d/default.conf.tpl \
     > /etc/nginx/conf.d/default.conf
 nginx -g 'daemon off;'