> ## Documentation Index
> Fetch the complete documentation index at: https://www.aptible.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring Nginx proxies on Aptible

Nginx is a popular choice for building custom reverse proxies on Aptible. When you deploy Nginx as an App on the platform, you are responsible for its configuration and maintenance.

This guide helps you avoid a common pitfall when configuring your Nginx app to route requests to Aptible [Endpoints](/core-concepts/apps/connecting-to-apps/app-endpoints/overview) using a `proxy_pass` directive.

## The problem: DNS caching in Nginx

By default, Nginx caches the IP addresses of upstream servers indefinitely and ignores DNS TTLs. Aptible Endpoints use AWS load balancers, which periodically change IP addresses. This mismatch causes Nginx to eventually route traffic to stale IPs.

Avoid this configuration pattern:

```nginx theme={null}
location / {
    proxy_pass https://hostname-of-an-endpoint;
}
```

## The solution: Configure the resolver directive

Configure the `resolver` directive to dynamically resolve upstream servers. Though any public DNS server could be used here (such as Google or Cloudflare), we recommend using the AWS VPC DNS Resolver `169.254.169.253` with a short TTL to ensure Nginx resolves DNS regularly (in the example below we use 60 seconds).

```nginx theme={null}
resolver 169.254.169.253 valid=60s;
set $upstream_endpoint https://hostname-of-an-endpoint;

location / {
    proxy_pass $upstream_endpoint;
}
```

<Note>
  The AWS VPC DNS Resolver (`169.254.169.253`) has some reasonable capacity limits, metered in packets per second per network interface. In typical use, it is very unlikely for a typical deployment to reach this limit. In the rare case that you're seeing persistent DNS resolution issues while using the AWS VPC DNS Resolver, please reach out to the [Aptible Support team](/how-to-guides/troubleshooting/aptible-support).
</Note>
