Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cloud api proxy (#7948) #7954

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;'
Loading