|
| 1 | +--- |
| 2 | +title: "Reverse proxy" |
| 3 | +description: "Configure a custom reverse proxy to serve your documentation" |
| 4 | +--- |
| 5 | + |
| 6 | +<Note> |
| 7 | + Reverse proxy configurations are only supported for [Custom plans](https://mintlify.com/pricing?ref=reverse-proxy). |
| 8 | +</Note> |
| 9 | + |
| 10 | +To serve your documentation through a custom reverse proxy, you must configure routing rules, caching policies, and header forwarding. |
| 11 | + |
| 12 | +When you implement a reverse proxy, monitor for potential issues with domain verification, SSL certificate provisioning, authentication flows, performance, and analytics tracking. |
| 13 | + |
| 14 | +## Routing configuration |
| 15 | + |
| 16 | +Proxy these paths to your Mintlify subdomain with the specified caching policies: |
| 17 | + |
| 18 | +| Path | Destination | Caching | |
| 19 | +|------|-------------|---------| |
| 20 | +| `/.well-known/acme-challenge/*` | `<your-subdomain>.mintlify.app` | No cache | |
| 21 | +| `/.well-known/vercel/*` | `<your-subdomain>.mintlify.app` | No cache | |
| 22 | +| `/mintlify-assets/_next/static/*` | `<your-subdomain>.mintlify.app` | Cache enabled | |
| 23 | +| `/*` | `<your-subdomain>.mintlify.app` | No cache | |
| 24 | +| `/` | `<your-subdomain>.mintlify.app` | No cache | |
| 25 | + |
| 26 | +## Required header configuration |
| 27 | + |
| 28 | +Configure your reverse proxy with these header requirements: |
| 29 | + |
| 30 | +- **Origin**: Contains the target subdomain `<your-subdomain>.mintlify.app` |
| 31 | +- **X-Forwarded-For**: Preserves client IP information |
| 32 | +- **X-Forwarded-Proto**: Preserves original protocol (HTTP/HTTPS) |
| 33 | +- **X-Real-IP**: Forwards the real client IP address |
| 34 | +- **User-Agent**: Forwards the user agent |
| 35 | + |
| 36 | +<Warning> |
| 37 | + Ensure that the `Host` header is not forwarded |
| 38 | +</Warning> |
| 39 | + |
| 40 | +## Example nginx configuration |
| 41 | + |
| 42 | +```nginx |
| 43 | +server { |
| 44 | + listen 80; |
| 45 | + server_name <your-domain>.com; |
| 46 | +
|
| 47 | + # Let's Encrypt verification paths |
| 48 | + location ~ ^/\.well-known/acme-challenge/ { |
| 49 | + proxy_pass https://<your-subdomain>.mintlify.app; |
| 50 | + proxy_set_header Origin <your-subdomain>.mintlify.app; |
| 51 | + proxy_set_header X-Real-IP $remote_addr; |
| 52 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 53 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 54 | + proxy_set_header User-Agent $http_user_agent; |
| 55 | +
|
| 56 | + # Disable caching for verification paths |
| 57 | + add_header Cache-Control "no-cache, no-store, must-revalidate"; |
| 58 | + } |
| 59 | +
|
| 60 | + # Vercel verification paths |
| 61 | + location ~ ^/\.well-known/vercel/ { |
| 62 | + proxy_pass https://<your-subdomain>.mintlify.app; |
| 63 | + proxy_set_header Origin <your-subdomain>.mintlify.app; |
| 64 | + proxy_set_header X-Real-IP $remote_addr; |
| 65 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 66 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 67 | + proxy_set_header User-Agent $http_user_agent; |
| 68 | +
|
| 69 | + # Disable caching for verification paths |
| 70 | + add_header Cache-Control "no-cache, no-store, must-revalidate"; |
| 71 | + } |
| 72 | +
|
| 73 | + # Static assets with caching |
| 74 | + location ~ ^/mintlify-assets/_next/static/ { |
| 75 | + proxy_pass https://<your-subdomain>.mintlify.app; |
| 76 | + proxy_set_header Origin <your-subdomain>.mintlify.app; |
| 77 | + proxy_set_header X-Real-IP $remote_addr; |
| 78 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 79 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 80 | + proxy_set_header User-Agent $http_user_agent; |
| 81 | +
|
| 82 | + # Enable caching for static assets |
| 83 | + add_header Cache-Control "public, max-age=86400"; |
| 84 | + } |
| 85 | +
|
| 86 | + # Root path |
| 87 | + location = / { |
| 88 | + proxy_pass https://<your-subdomain>.mintlify.app; |
| 89 | + proxy_set_header Origin <your-subdomain>.mintlify.app; |
| 90 | + proxy_set_header X-Real-IP $remote_addr; |
| 91 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 92 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 93 | + proxy_set_header User-Agent $http_user_agent; |
| 94 | +
|
| 95 | + # Disable caching for dynamic content |
| 96 | + add_header Cache-Control "no-cache, no-store, must-revalidate"; |
| 97 | + } |
| 98 | +
|
| 99 | + # All other documentation paths |
| 100 | + location / { |
| 101 | + proxy_pass https://<your-subdomain>.mintlify.app; |
| 102 | + proxy_set_header Origin <your-subdomain>.mintlify.app; |
| 103 | + proxy_set_header X-Real-IP $remote_addr; |
| 104 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 105 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 106 | + proxy_set_header User-Agent $http_user_agent; |
| 107 | +
|
| 108 | + # Disable caching for dynamic content |
| 109 | + add_header Cache-Control "no-cache, no-store, must-revalidate"; |
| 110 | + } |
| 111 | +} |
| 112 | +``` |
| 113 | + |
| 114 | +## Troubleshooting |
| 115 | + |
| 116 | +### 404 error |
| 117 | + |
| 118 | +**Symptoms**: Documentation loads, but features don't work. API calls fail. |
| 119 | + |
| 120 | +**Cause**: `Host` header is being forwarded or `Origin` header is missing. |
| 121 | + |
| 122 | +**Solution**: |
| 123 | + |
| 124 | +- Remove `Host` header forwarding |
| 125 | +- Set `Origin` header to `<your-subdomain>.mintlify.app` |
| 126 | + |
| 127 | +### Performance issues |
| 128 | + |
| 129 | +**Symptoms**: Slow page loads and layout shifts. |
| 130 | + |
| 131 | +**Cause**: Incorrect caching configuration. |
| 132 | + |
| 133 | +**Solution**: Enable caching only for `/mintlify-assets/_next/static/*` paths. |
0 commit comments