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

# Proxy Trfyx with DigitalOcean

> Proxy Trfyx analytics with a DigitalOcean Droplet and Nginx.

If your application runs on a DigitalOcean Droplet, the simplest self-hosted setup is Nginx.

<Steps>
  <Step title="Configure Nginx">
    Use the [Nginx proxy configuration](/nginx-proxy) on your Droplet and make sure your domain points to the Droplet.

    ```nginx nginx.conf theme={"dark"}
    location = /script.js {
        proxy_pass https://app.trfyx.com/script.js;
        proxy_set_header Host app.trfyx.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;
    }

    location = /api/events {
        proxy_pass https://app.trfyx.com/api/events;
        proxy_set_header Host app.trfyx.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>

  <Step title="Add optional script caching">
    The script can be cached at the edge or by Nginx to reduce repeated upstream requests. Keep event requests uncached.
  </Step>

  <Step title="Update the tracker">
    Replace the default Trfyx script with the proxied path:

    ```html index.html theme={"dark"}
    <script
      defer
      data-website-id="YOUR_TRFYX_PROJECT_ID"
      data-domain="yourdomain.com"
      src="/script.js"
    ></script>
    ```
  </Step>

  <Step title="Verify installation">
    Test and reload Nginx:

    ```bash Terminal theme={"dark"}
    sudo nginx -t
    sudo systemctl reload nginx
    ```

    Open your website and confirm `script.js` and `/api/events` use your own hostname. Check Trfyx for incoming activity.
  </Step>
</Steps>

<Note>
  If you do not need to manage a server, use [Managed Proxy](/managed-proxy) instead. It is less operational work and avoids maintaining proxy code.
</Note>

## Next steps

<CardGroup cols={2}>
  <Card title="Proxy setup" icon="signs-post" href="/proxy-guide">
    Read the full proxy setup guide
  </Card>

  <Card title="Managed Proxy" icon="shield-halved" href="/managed-proxy">
    Let Trfyx manage the proxy for you
  </Card>

  <Card title="Goals" icon="bullseye" href="/goals">
    Start tracking goals with Trfyx
  </Card>

  <Card title="Troubleshooting" icon="life-ring" href="/troubleshooting">
    Fix common proxy issues
  </Card>
</CardGroup>


## Related topics

- [Proxy Trfyx through your domain](/proxy-guide.md)
- [Welcome to Trfyx](/index.md)
- [Proxy Trfyx with Laravel](/laravel-proxy.md)
- [Proxy Trfyx with Astro](/astro-proxy.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.