Skip to content

Commit

Permalink
add cloud api proxy (#7948) (#7954)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangNing10 authored Aug 26, 2024
1 parent e3c0b2e commit d11b6d9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions config-ui/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}";
Expand Down
2 changes: 1 addition & 1 deletion config-ui/nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;'

0 comments on commit d11b6d9

Please sign in to comment.