Skip to content

Commit

Permalink
Remove proxy service and make API NGINX setup similar to the fronte…
Browse files Browse the repository at this point in the history
…nd (#4605)
  • Loading branch information
dhruvkb authored Jul 16, 2024
1 parent 90f87b8 commit 25a8021
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 151 deletions.
3 changes: 2 additions & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ LABEL org.opencontainers.image.source="https://github.com/WordPress/openverse"

WORKDIR /app

COPY nginx.conf.template /etc/nginx/templates/openverse-api.conf.template
COPY nginx/nginx.conf.template /etc/nginx/templates/openverse-api.conf.template
COPY nginx/snippets /etc/nginx/snippets

# Copy static files from `api` target
COPY --from=api /static /app/static
Expand Down
19 changes: 2 additions & 17 deletions api/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ services:
cache:
profiles:
- api
- api_extra
image: docker.io/redis:7.2.5
ports:
- "50263:6379"

web:
profiles:
- api
- api_extra
build:
target: api
additional_contexts:
Expand Down Expand Up @@ -47,24 +45,11 @@ services:
- SEMANTIC_VERSION=${SEMANTIC_VERSION:-v1.0.0}
- API_PY_VERSION
- PDM_INSTALL_ARGS=--dev
image: openverse-api_nginx:${API_PDM_HASH:-latest}
pull_policy: never
ports:
- "50270:8080"
environment:
DJANGO_NGINX_UPSTREAM_URL: web:50280
depends_on:
- web

proxy:
profiles:
- api_extra
image: docker.io/nginx:alpine
ports:
- "50200:9080"
- "50243:9443"
environment:
HTTPS_PORT: 50243 # See `ports` mapping above.
depends_on:
- web
volumes:
- ../docker/nginx/templates:/etc/nginx/templates:z
- ../docker/nginx/certs:/etc/nginx/certs:z
2 changes: 1 addition & 1 deletion api/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ up *flags:

# Bring up services specific to the API profile, in addition to the API server
up-extra *flags:
env COMPOSE_PROFILES="api_extra" just ../up {{ flags }}
env COMPOSE_PROFILES="api,api_extra" just ../up {{ flags }}

# Wait for all profile services to be up
wait-up: up
Expand Down
14 changes: 2 additions & 12 deletions api/nginx.conf.template → api/nginx/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,11 @@ server {
}

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://django;
error_page 500 /500.json;
include snippets/django_location.conf;
}

location ~ ^/(v1|admin)/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://django;
error_page 500 /500.json;
include snippets/django_location.conf;
}

location /500.json {
Expand Down
6 changes: 6 additions & 0 deletions api/nginx/snippets/django_location.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://django;
error_page 500 /500.json;
1 change: 0 additions & 1 deletion docker/nginx/.gitignore

This file was deleted.

19 changes: 0 additions & 19 deletions docker/nginx/justfile

This file was deleted.

24 changes: 0 additions & 24 deletions docker/nginx/templates/web.conf.template

This file was deleted.

55 changes: 0 additions & 55 deletions documentation/api/guides/https.md

This file was deleted.

1 change: 0 additions & 1 deletion documentation/api/guides/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ quickstart
test
deploy
documentation
https
```
19 changes: 0 additions & 19 deletions documentation/general/https.md

This file was deleted.

1 change: 0 additions & 1 deletion documentation/general/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ test
zero_downtime_database_management
deployment
logging
https
stack
```

0 comments on commit 25a8021

Please sign in to comment.