How can we help?

How to use same origin through Caddy

Uliana Lesiv
Uliana Lesiv
  • Updated

If Caddy is already your primary web server or reverse proxy, you can also configure it to proxy your server GTM requests. Start by updating your configuration, as shown in the next step below.

This guide 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 server GTM container instead of https://sgtm.example.com.

 

Step 1: Update your Caddyfile

Add the following to your Caddyfile:

 

@sgtm path /metrics
handle @sgtm {
        reverse_proxy https://sgtm.example.com {
            header_up X-Forwarded-For {remote_host}
            header_up X-From-Cdn "cf-stape"
            header_up CF-Connecting-Ip {remote_host}
            header_up Host sgtm.example.com
        }
    }

 

Step 2: Test changes

 

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, it means 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.

 

 

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.