DigitalOcean proxy

Proxy attribu.tech analytics through DigitalOcean App Platform or Droplet.

This is a server-specific guide. See Proxy the tracking script for an overview of why and how proxying works.

Option 1: App Platform

If you're running a Node.js app on DigitalOcean App Platform, use the Next.js or Express.js proxy guide depending on your framework. App Platform automatically sets X-Forwarded-For headers, so visitor IP addresses will be forwarded correctly without extra configuration.

Option 2: Droplet with Nginx

If you're running a Droplet, add proxy rules to your Nginx configuration.

SSH into your Droplet

ssh root@your-droplet-ip

Edit your Nginx config

Open your site configuration file:

sudo nano /etc/nginx/sites-available/your-site

Add the following location blocks inside your server block:

server {
    listen 80;
    server_name yourdomain.com;

    # Your existing configuration ...

    # Proxy the attribu.tech tracking script
    location /js/attribu.js {
        proxy_pass https://attribu.tech/js/script.js;
        proxy_set_header Host attribu.tech;
        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;
        proxy_ssl_server_name on;
    }

    # Proxy the attribu.tech event API
    location /api/proxy/events {
        proxy_pass https://attribu.tech/api/events;
        proxy_set_header Host attribu.tech;
        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;
        proxy_ssl_server_name on;
    }
}

Test and reload Nginx

sudo nginx -t && sudo systemctl reload nginx

Update your script tag

Point the script src to your proxied path and set data-api-url to your proxied API endpoint:

<script
  defer
  data-website-id="YOUR_SITE_ID"
  data-domain="yourdomain.com"
  data-api-url="https://yourdomain.com/api/proxy/events"
  src="/js/attribu.js"
></script>
Replace YOUR_SITE_ID with your actual Website ID from attribu.tech. Replace yourdomain.com with your website's root domain.

Verify installation

  1. Visit your site in an incognito/private window.
  2. Open your browser's Developer Tools and go to the Network tab.
  3. Confirm the script loads from /js/attribu.js on your domain.
  4. Confirm the pageview POST goes to /api/proxy/events on your domain.
  5. Check your attribu.tech dashboard. A new pageview should appear within a few seconds.

Troubleshooting

  • 502 Bad Gateway - Make sure your Droplet can reach attribu.tech over HTTPS. Check DNS and firewall rules. Ensure proxy_ssl_server_name on is set.
  • Script loads but no pageviews - Verify the /api/proxy/events location block is present and that Nginx was reloaded after editing the config.
  • CORS errors - The proxy should eliminate CORS issues since both the script and API are served from your domain. If you still see errors, make sure the proxy is not adding extra CORS headers that conflict.

What's next

Copied