How to use same origin through Apache HTTP Server
Updated Mar 28, 2025
If you're already running Apache HTTP Server as your main web server or reverse proxy, you can also configure it to proxy your server GTM request. Begin by adjusting your configuration, as shown in the next step.
This instruction uses /metrics as an example of the same origin path. You can use any of your own.
You should also use the URL of your sGTM container instead of https://sgtm.example.com.
Step 1: Enable the required modules
sudo a2enmod proxy
sudo a2enmod proxy_httpsudo a2enmod ssl
Step 2: Update your config
ServerName website.com
ProxyRequests off
ProxyPreserveHost off
SSLProxyEngine on
RequestHeader set X-Forwarded-For "%{REMOTE_ADDR}e"
RequestHeader set X-From-Cdn "cf-stape"
RequestHeader set CF-Connecting-Ip "%{REMOTE_ADDR}e"
RequestHeader set HOST "sgtm.example.com"
ProxyPass"https://sgtm.example.com"
ProxyPassReverse "https://sgtm.example.com"
Step 3: Adjust your deployed script
Deploy the changes to your site.
You can verify the proxy is working by opening your proxy path in the browser. Go to https://sgtm.example.com/metrics. If you see error 400, then everything is working correctly. You can also run a preview of the server container on your /metrics path.
After following these steps, add your /path for the same origin to the Custom Loader's settings. Check the article on Same Origin Path to do this.