Apache proxy

Proxy attribu.tech analytics through Apache with mod_proxy.

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

Enable required modules

Make sure mod_proxy and mod_proxy_http are enabled. On Debian/Ubuntu:

sudo a2enmod proxy proxy_http ssl
sudo systemctl restart apache2

VirtualHost configuration

Add these ProxyPass directives inside your <VirtualHost> block:

<VirtualHost *:443>
    ServerName yourdomain.com

    # Enable SSL proxying
    SSLProxyEngine On

    # Proxy the attribu.tech tracking script
    ProxyPass        /js/attribu.js https://attribu.tech/js/script.js
    ProxyPassReverse /js/attribu.js https://attribu.tech/js/script.js

    # Proxy the attribu.tech event API
    ProxyPass        /api/proxy/events https://attribu.tech/api/events
    ProxyPassReverse /api/proxy/events https://attribu.tech/api/events

    # Forward the visitor's real IP
    ProxyPreserveHost Off
    RequestHeader set X-Forwarded-For "%{REMOTE_ADDR}s"

    # Your existing site config below
    # ...
</VirtualHost>
If you use port 80 (HTTP), change *:443 to *:80 and remove the SSLProxyEngine On line. HTTPS is strongly recommended for production.

Test the config and reload Apache:

sudo apachectl configtest && sudo systemctl reload apache2

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.

What's next

Copied