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

# Nginx

> Proxy PostMetric with Nginx

Proxy PostMetric through your Nginx server.

## Setup

### Step 1: Add proxy configuration

Add this to your Nginx configuration:

```nginx theme={null}
location /api/track.js {
    proxy_pass https://your-postmetric-domain.com/api/track.js;
    proxy_set_header Host your-postmetric-domain.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

    # Set content type
    add_header Content-Type application/javascript;
}

location /api/track {
    proxy_pass https://your-postmetric-domain.com/api/track;
    proxy_set_header Host your-postmetric-domain.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}
```

### Step 2: Reload Nginx

```bash theme={null}
sudo nginx -t
sudo systemctl reload nginx
```

### Step 3: Update tracking script URL

Update your tracking script to use your domain:

```html theme={null}
<script src="https://your-domain.com/api/track.js?site=YOUR_TRACKING_CODE"></script>
```

## Next steps

<Card title="Proxy setup guide" icon="shield" href="/proxy/get-started">
  Learn more about proxying PostMetric
</Card>
