bazelbuild / bazelbuild/continuous-integration

Setup HTTP redirects using Google Cloud Traffic Management

Open
#1,169 3 comments 0 reactions 1 assignee Claimed by @coeuvre View on GitHub
FR P2
Dominant language
Python
Stars
302
Forks
194
Avg merge
1d 19h
Merged PRs (30d)
41

Description

Bazel's websites are behind two Google Cloud Load Balancers:

- `http-redirector` listening on `130.211.20.222:80`, `130.211.20.222:443` and `130.211.22.235:80`
- `bazel-build` listening on `130.211.22.235:443`

The `http-redirector` LB forwards all requests to an nginx instance running on a VM with this config:

```
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

# Redirect variations of the main website URL to the canonical one.
server {
listen 80;
server_name bazel.build www.bazel.build bazel.io www.bazel.io;
return 301 https://bazel.build$request_uri;
}

# Redirect http:// to https:// and *.bazel.io to *.bazel.build.
server {
listen 80;
server_name ~^(?.+)\.bazel\.(?.+)$;
return 301 https://$subdomain.bazel.build$request_uri;
}

# Redirect http(s)://ci.bazel.build/ to a new site.
server {
listen 80;
server_name ci.bazel.build;
return 301 https://github.com/bazelbuild/continuous-integration/blob/master/buildkite/README.md;
}

# Catch-all default server that just returns an error.
server {
listen 80 default_server;
server_name _;
add_header Content-Type text/plain;
return 200 "Bazel Redirection Service";
}
}
```

The full list of domains that are handled by the load balancers is:

```
bazel.foo -> 130.211.20.222
www.bazel.foo -> 130.211.22.235
tulsi.bazel.foo -> 130.211.22.235
ij.bazel.foo -> 130.211.22.235
skydoc.bazel.foo -> 130.211.22.235

bazel.io -> 130.211.20.222
www.bazel.io -> 130.211.20.222
tulsi.bazel.io -> 130.211.20.222
ij.bazel.io -> 130.211.20.222
skydoc.bazel.io -> 130.211.20.222

bazel.build -> 130.211.22.235
bcr.bazel.build -> 130.211.22.235
be.bazel.build -> 130.211.22.235
blog.bazel.build -> 130.211.22.235
ci.bazel.build -> 130.211.22.235
ci-staging.bazel.build -> 130.211.22.235
cr.bazel.build -> 130.211.22.235
cs.bazel.build -> 130.211.22.235
dashboard.bazel.build -> 130.211.22.235
docs.bazel.build -> 130.211.22.235
docs-staging.bazel.build -> 130.211.22.235
eclipse.bazel.build -> 130.211.22.235
ij.bazel.build -> 130.211.22.235
mirror.bazel.build -> 130.211.22.235
perf.bazel.build -> 130.211.22.235
releases.bazel.build -> 130.211.22.235
skydoc.bazel.build -> 130.211.22.235
tulsi.bazel.build -> 130.211.22.235
www.bazel.build -> 130.211.22.235
```

(For some unknown reason, the *.foo domains apparently do not work at the moment. 🤷🏻)

The idea behind this setup is that we want to do various kind of rewrites:
- Redirect old `*.io` domains to new `*.build` domains.
- Redirect `www.bazel.build` to `bazel.build`.
- Redirect `http://` URLs to `https://` URLs.
- Redirect `ci.bazel.build` to `https://github.com/bazelbuild/continuous-integration/blob/master/buildkite/README.md`.

The nginx VM was necessary because Google Cloud could not do these kind of rewrites for a long time. However, since 2020 a new feature called [Traffic Management](https://cloud.google.com/load-balancing/docs/https/traffic-management) is available and it looks like it should support this.

The goals of this project would be:
- Simplify our load-balancer configuration (ideally remove the `http-redirect` one completely).
- Shutdown and remove the `http-redir` VM.
- Implement the additional rewrite rule for https://github.com/bazelbuild/bazel/pull/13519: Redirect `https://docs.bazel.build/versions/master/...` to `https://docs.bazel.build/versions/main/...` (but only once documentation is being published under this new URL).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.