From 3c0506638912b524fe1bc17eec96278f99361a7a Mon Sep 17 00:00:00 2001 From: Oksamies Date: Mon, 23 Sep 2024 14:21:48 +0300 Subject: [PATCH] Add a version of ts-proxy tool; that uses dev backend --- tools/ts-dev-proxy/Dockerfile | 5 + tools/ts-dev-proxy/docker-compose.yml | 6 + tools/ts-dev-proxy/nginx.conf | 223 ++++++++++++++++++++++++++ 3 files changed, 234 insertions(+) create mode 100644 tools/ts-dev-proxy/Dockerfile create mode 100644 tools/ts-dev-proxy/docker-compose.yml create mode 100644 tools/ts-dev-proxy/nginx.conf diff --git a/tools/ts-dev-proxy/Dockerfile b/tools/ts-dev-proxy/Dockerfile new file mode 100644 index 000000000..b952f685b --- /dev/null +++ b/tools/ts-dev-proxy/Dockerfile @@ -0,0 +1,5 @@ +FROM nginx:alpine +WORKDIR /usr/share/nginx/html +RUN rm -rf ./* + +COPY ./nginx.conf /etc/nginx/nginx.conf diff --git a/tools/ts-dev-proxy/docker-compose.yml b/tools/ts-dev-proxy/docker-compose.yml new file mode 100644 index 000000000..01f6601e5 --- /dev/null +++ b/tools/ts-dev-proxy/docker-compose.yml @@ -0,0 +1,6 @@ + +services: + nginx: + build: . + ports: + - "127.0.0.1:80:80" diff --git a/tools/ts-dev-proxy/nginx.conf b/tools/ts-dev-proxy/nginx.conf new file mode 100644 index 000000000..5b57fd4a9 --- /dev/null +++ b/tools/ts-dev-proxy/nginx.conf @@ -0,0 +1,223 @@ +worker_processes 2; +worker_rlimit_nofile 20000; + +events { + worker_connections 10000; + multi_accept on; +} +http { + server { + listen 80; + gzip on; + gzip_proxied any; + gzip_disable "msie6"; + gzip_types + text/css + text/javascript + text/xml + text/plain + text/x-component + application/javascript + application/json + application/xml + application/rss+xml + font/truetype + font/opentype + application/vnd.ms-fontobject + image/svg+xml; + gzip_min_length 256; + gunzip on; + + location = /communities { + proxy_pass http://host.docker.internal:3000/communities; + proxy_set_header Host thunderstore.temp; + proxy_set_header X-Forwarded-For $remote_addr; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location = /site.webmanifest { + proxy_pass http://host.docker.internal:3000/site.webmanifest; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location = /favicon-32x32.png { + proxy_pass http://host.docker.internal:3000/favicon-32x32.png; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location = /favicon-16x16.png { + proxy_pass http://host.docker.internal:3000/favicon-16x16.png; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location = /android-chrome-192x192.png { + proxy_pass http://host.docker.internal:3000/android-chrome-192x192.png; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /teams { + proxy_pass http://host.docker.internal:3000/teams; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /c { + proxy_pass http://host.docker.internal:3000/c; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /settings { + proxy_pass http://host.docker.internal:3000/settings; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /tools { + proxy_pass http://host.docker.internal:3000/tools; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /package/create/docs { + proxy_pass http://host.docker.internal:3000/package/create/docs; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + # location /u { + # proxy_pass http://host.docker.internal:3000/u; + # } + + # location /developers { + # proxy_pass http://host.docker.internal:3000/developers; + # } + + location /__remix/healthz { + proxy_pass http://host.docker.internal:3000/healthz; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + # For when running built remix + location /__remix/ { + proxy_pass http://host.docker.internal:3000/__remix/; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + # For when running dev remix + location /node_modules/ { + proxy_pass http://host.docker.internal:3000/node_modules/; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /app/ { + proxy_pass http://host.docker.internal:3000/app/; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /@vite/ { + proxy_pass http://host.docker.internal:3000/@vite/; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /@fs/ { + proxy_pass http://host.docker.internal:3000/@fs/; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /@id/__x00__sentry-release-injection-file { + proxy_pass http://host.docker.internal:3000/@id/__x00__sentry-release-injection-file; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /@id/__x00__virtual:remix/browser-manifest { + proxy_pass http://host.docker.internal:3000/@id/__x00__virtual:remix/browser-manifest; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /@id/__x00__virtual:remix/inject-hmr-runtime { + proxy_pass http://host.docker.internal:3000/@id/__x00__virtual:remix/inject-hmr-runtime; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /@id/__x00__virtual:remix/hmr-runtime { + proxy_pass http://host.docker.internal:3000/@id/__x00__virtual:remix/hmr-runtime; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /remixhmr { + proxy_pass http://host.docker.internal:3000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /socket { + proxy_pass http://host.docker.internal:3000/socket; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host thunderstore.temp; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location / { + proxy_pass http://host.docker.internal:81; + proxy_http_version 1.1; + proxy_set_header Host thunderstore.temp; + # proxy_ssl_name thunderstore.io; + # proxy_ssl_server_name on; + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Headers *; + } + + location /gateway/healthz { + access_log off; + return 200 "healthy\\n"; + } + } +}