Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Add ability to configure Nginx DNS resolver (#3275)

sarayourfriend479095f3a60b
diff --git a/docker-compose.yml b/docker-compose.yml
index 2634a5947..b91a3d838 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -334,6 +334,10 @@ services:
environment:
OPENVERSE_NGINX_UPSTREAM_URL: ${HOST_NETWORK_ADDRESS}:8443
OPENVERSE_NGINX_PLAUSIBLE_EVENT_URL: http://plausible:8000/api/event
+ # Set to Docker network resolver to be able to resolve the `plausible` container.
+ # This would be the default but Nginx requires it to be explicitly set when
+ # making outgoing requests (e.g., to plausible.io)
+ OPENVERSE_NGINX_DNS_RESOLVER: 127.0.0.11
volumes:
api-postgres:
diff --git a/frontend/nginx.conf.template b/frontend/nginx.conf.template
index 004092aaf..90d045076 100644
--- a/frontend/nginx.conf.template
+++ b/frontend/nginx.conf.template
@@ -5,6 +5,7 @@
# - OPENVERSE_NGINX_GIT_REVISION
# - OPENVERSE_NGINX_ENVIRONMENT
# - OPENVERSE_NGINX_PLAUSIBLE_EVENT_URL
+# - OPENVERSE_NGINX_DNS_RESOLVER
error_log /var/log/nginx/error.log;
@@ -69,7 +70,7 @@ server {
# This is Docker's internal DNS resolver
# In localhost it will resolve the local Plausible and forward anything else to the host
# In production, AWS replaces
- resolver 127.0.0.11;
+ resolver $OPENVERSE_NGINX_DNS_RESOLVER;
set $plausible_event_url $OPENVERSE_NGINX_PLAUSIBLE_EVENT_URL;
location = /api/event {
proxy_pass $plausible_event_url;