Any way to pass autonomous system name as a header?

Hello there,

one of my customers has an use-case where they would benefit from receiving the autonomous system name as a header from a transform rule. Currently I am passing the ASN with the available field ip.src.asnum.

As I’m aware, there’s no field which would allow for the AS name to be passed, nor any other way or feature from CF which would allow for passing of the AS name.

Just wondering if there’s any way to do this, maybe using one of the paid plans, or if I have to resort to resolving the AS name locally from a vendor database. Thank you!

The only thing that I am aware of that has the ASN name is the cf object on workers, so you would have to use a worker in front of your site to pass that on. It is probably cheaper to have the server look it up.

2 Likes

See this post:

You can use a Transform Rule to add ip.geoip.asnum as a dynamic header.

1 Like

This doesn’t work for some reason. I added new header with name “X_ASN”, value = “ip.geoip.asnum” (or to_string(ip.geoip.asnum))

Bu in response header I see “ip.geoip.asnum”, not ASN number, just text.

It worked for me. You need to set a dynamic header instead of static. Also, you just need to put ip.geoip.asnum without any additional string as value.

2 Likes

Thanks a lot! It works. I can see this header in browser (->network), but how to get in in PHP? It’s not in $_SERVER (surprise…) variable.

If the header is x-mysite-cf-asn then it will be in $_SERVER['HTTP_X_MYSITE_CF_ASN']

1 Like

It was my mistake - I added response header, but for my PHP it, of cource - request header. Now it works fine - thanks everybody for help!

1 Like