[gbm-web] redirector: Switch to CDN77
- From: Bartłomiej Piotrowski <bpiotrowski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbm-web] redirector: Switch to CDN77
- Date: Sat, 22 Jan 2022 20:52:08 +0000 (UTC)
commit d691c9b0daf8ffd585215d7a0979180e0ad1e720
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date: Sat Jan 22 21:51:53 2022 +0100
redirector: Switch to CDN77
redirector/Dockerfile | 5 ++---
redirector/main.py | 11 +++++------
redirector/nginx.conf | 40 ----------------------------------------
redirector/requirements.txt | 16 ----------------
4 files changed, 7 insertions(+), 65 deletions(-)
---
diff --git a/redirector/Dockerfile b/redirector/Dockerfile
index 9105200..465d6a9 100644
--- a/redirector/Dockerfile
+++ b/redirector/Dockerfile
@@ -1,4 +1,4 @@
-FROM python:3.8-slim
+FROM python:3.10-slim
EXPOSE 8000
ENV PYTHONPATH=/app
@@ -8,8 +8,7 @@ RUN apt-get update && apt-get install -y nginx-light curl && \
ln -sf /dev/stderr /var/log/nginx/error.log && \
apt-get clean && rm -rf /var/lib/apt/lists/*
-COPY requirements.txt /requirements.txt
-RUN pip install -r /requirements.txt && rm -f /requirements.txt
+RUN pip install fastapi uvicorn requests
COPY ./ /app
ADD nginx.conf /etc/nginx/nginx.conf
diff --git a/redirector/main.py b/redirector/main.py
index 3c1cb43..c3ddb77 100644
--- a/redirector/main.py
+++ b/redirector/main.py
@@ -7,8 +7,7 @@ from pydantic import BaseSettings
class Settings(BaseSettings):
- bucket_url: str = "https://gnome-build-meta.s3.amazonaws.com"
- bucket_name: str = "gnome-build-meta"
+ cdn_url: str = "https://1270333429.rsc.cdn77.org"
mirror_url: str = "https://download.gnome.org/gnomeos"
volume_path: str = "/ftp/pub/GNOME/gnomeos"
main_url: str = "https://os.gnome.org"
@@ -32,7 +31,7 @@ def get_nightly(filename: str):
else:
return Response(status_code=status.HTTP_404_NOT_FOUND)
- r = requests.get(f"{cfg.bucket_url}/{latest_filename}")
+ r = requests.get(f"{cfg.cdn_url}/{latest_filename}")
latest = r.text.rstrip()
directory, version, filename = latest.split("/")
@@ -51,12 +50,12 @@ def get_versioned(version: str, filename: str):
response.status_code = status.HTTP_302_FOUND
return response
- # Otherwise, redirect to S3
+ # Otherwise, redirect to CDN/S3
if "." in version:
folder = "tag"
else:
folder = "nightly"
- response = RedirectResponse(f"{cfg.bucket_url}/{folder}/{version}/{filename}")
- response.status_code = status.HTTP_301_MOVED_PERMANENTLY
+ response = RedirectResponse(f"{cfg.cdn_url}/{folder}/{version}/{filename}")
+ response.status_code = status.HTTP_302_FOUND
return response
diff --git a/redirector/nginx.conf b/redirector/nginx.conf
index cc646b3..5a603ad 100644
--- a/redirector/nginx.conf
+++ b/redirector/nginx.conf
@@ -30,9 +30,6 @@ http {
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
- proxy_cache_path /cache/ levels=1:2 keys_zone=s3cache:10m max_size=50g
- inactive=30d use_temp_path=off;
-
server {
listen 8080 default_server;
listen [::]:8080 default_server;
@@ -46,43 +43,6 @@ http {
}
location /download/ {
- proxy_intercept_errors on;
- error_page 301 = @s3cache;
- error_page 302 = @mirror;
-
proxy_pass http://localhost:8000/;
}
-
- location @mirror {
- return 301 $upstream_http_location;
- }
-
- location @s3cache {
- resolver 1.1.1.1;
- set $original_uri $uri;
- set $redirect_location '$upstream_http_location';
-
- proxy_http_version 1.1;
- proxy_set_header Connection "";
- proxy_set_header Authorization '';
- proxy_set_header Host gnome-build-meta.s3.amazonaws.com;
- proxy_hide_header x-amz-id-2;
- proxy_hide_header x-amz-request-id;
- proxy_hide_header x-amz-meta-server-side-encryption;
- proxy_hide_header x-amz-server-side-encryption;
- proxy_hide_header Set-Cookie;
- proxy_ignore_headers Set-Cookie;
- proxy_cache_revalidate on;
- proxy_intercept_errors on;
- proxy_pass $redirect_location;
-
- proxy_cache s3cache;
- proxy_cache_key $original_uri;
- proxy_cache_valid 200 15d;
- proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
- proxy_cache_lock on;
- add_header Cache-Control max-age=31536000;
- add_header X-Cache-Status $upstream_cache_status;
- }
- }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]