This guide covers setting up a reverse proxy using Nginx, but the same principles apply to Apache, Caddy, HAProxy, or any other reverse proxy solution.
Prerequisites
- A server with a reverse proxy (Nginx, Apache, Caddy, etc.)
- SSL/TLS certificate for your domain
- Ability to modify proxy configuration
Nginx Configuration
Add the following to your Nginx configuration (typically in/etc/nginx/sites-available/yourdomain.conf):
Apache Configuration
For Apache withmod_proxy enabled:
Caddy Configuration
Caddy provides a simpler configuration:SDK Configuration
Once your proxy is running, configure the SDK:Required Headers
Your proxy must set these headers on requests to Composite:| Header | Value | Purpose |
|---|---|---|
X-Forwarded-For | Client IP | Track original visitor IP |
X-Forwarded-Proto | https | Maintain protocol information |
X-Real-IP | Client IP | Backup IP header |
Host | prod.alb.us.api.composite.com | Target host (do not forward client host) |
Troubleshooting
502 Bad Gateway errors
502 Bad Gateway errors
The proxy cannot reach Composite’s API:
- Verify DNS resolution:
nslookup prod.alb.us.api.composite.com - Test connectivity:
curl -I https://prod.alb.us.api.composite.com - Check your server’s outbound firewall rules
- Ensure SSL/TLS is properly configured for the upstream connection
404 errors on analytics endpoints
404 errors on analytics endpoints
Check your proxy configuration:
- Verify the location/path pattern matches
/analytics - Ensure the upstream URL is
https://prod.alb.us.api.composite.com - Test with:
curl https://yourdomain.com/analytics/health - Check proxy logs for the actual upstream URL being requested
CORS errors in browser
CORS errors in browser
The response is missing CORS headers:
- Ensure CORS headers are added to responses (not just requests)
- Check that OPTIONS preflight requests return 204 with CORS headers
- Verify
Access-Control-Allow-Originis set to*or your extension’s origin
SSL certificate errors
SSL certificate errors
For upstream connections:
- Ensure your proxy trusts the CA that signed Composite’s certificate
- Enable SNI (Server Name Indication) in your proxy config
- For Nginx, verify
proxy_ssl_server_name on;is set
Security Considerations
- Rate limiting: Consider adding rate limits to prevent abuse
- Logging: Log requests for debugging but avoid logging request bodies (may contain PII)
- Access control: If your extension is internal, consider IP allowlisting