# Irule header APM

**URL:** <https://community.f5.com/t/irule-header-apm/47376>\
**Category:** Technical Forums\
**Tags:** irules, security\
**Created:** [June 13, 2019, 2:04pm UTC](https://community.f5.com/t/irule-header-apm/47376 "2019-06-13T14:04:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean\_Mamène](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@Jean\_Mamène](https://community.f5.com/u/Jean_Mam%C3%A8ne)\
**Post date:** [June 13, 2019, 2:04pm UTC](https://community.f5.com/t/irule-header-apm/47376/1 "2019-06-13T14:04:53Z")

</div>

Hello,

The fact that the EXAMPLE \* header are eliminated by the F5 blocks any possibility of traceability of our messages within our information system for some VHOST.

I already set up irule to add some header but in this case I want the header is not reset.

Do you know an irule for that ?

Thanks in advance.

Regards,

---

<div class="post-metadata">

**Author:** ![Nicolas\_Destor](https://avatars.discourse-cdn.com/v4/letter/n/3d9bf3/32.png) [@Nicolas\_Destor](https://community.f5.com/u/Nicolas_Destor)\
**Post date:** [June 14, 2019, 8:08am UTC](https://community.f5.com/t/irule-header-apm/47376/2 "2019-06-14T08:08:18Z")

</div>

Hi,

Your question is not clear enough for me. Are you talking about the HTTP header? Can you provide an example of what you want to do ?

---

<div class="post-metadata">

**Author:** ![Jean\_Mamène](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@Jean\_Mamène](https://community.f5.com/u/Jean_Mam%C3%A8ne)\
**Post date:** [June 14, 2019, 8:12am UTC](https://community.f5.com/t/irule-header-apm/47376/3 "2019-06-14T08:12:21Z")

</div>

Hi Nicolas,

I would like the virtualhost [https://test.com](https://test.com) headers EXEMPLE\* to be preserved :

EXEMPLE\_TX\_ID

EXEMPLE\_SPAN\_ID

EXEMPLE\_PARENT\_SPAN\_ID

Regards,

---

<div class="post-metadata">

**Author:** ![Jean\_Mamène](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@Jean\_Mamène](https://community.f5.com/u/Jean_Mam%C3%A8ne)\
**Post date:** [June 18, 2019, 3:57pm UTC](https://community.f5.com/t/irule-header-apm/47376/4 "2019-06-18T15:57:34Z")

</div>

up

---

<div class="post-metadata">

**Author:** ![KeesvandenBos](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@KeesvandenBos](https://community.f5.com/u/KeesvandenBos)\
**Post date:** [June 18, 2019, 5:53pm UTC](https://community.f5.com/t/irule-header-apm/47376/5 "2019-06-18T17:53:34Z")

</div>

Hi,

To make it more clear (your question) you want the BIG-IP not to make any changes to the EXAMPLE\_TX\_ID and EXAMPLE\_SPAN\_ID header?

Cheers,

Kees

---

<div class="post-metadata">

**Author:** ![Jean\_Mamène](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@Jean\_Mamène](https://community.f5.com/u/Jean_Mam%C3%A8ne)\
**Post date:** [June 19, 2019, 7:21am UTC](https://community.f5.com/t/irule-header-apm/47376/6 "2019-06-19T07:21:19Z")

</div>

Hi Kees,

That’s right

Regards,

---

<div class="post-metadata">

**Author:** ![Nicolas\_Destor](https://avatars.discourse-cdn.com/v4/letter/n/3d9bf3/32.png) [@Nicolas\_Destor](https://community.f5.com/u/Nicolas_Destor)\
**Post date:** [June 19, 2019, 11:01am UTC](https://community.f5.com/t/irule-header-apm/47376/7 "2019-06-19T11:01:23Z")

</div>

Hi Jean,

My apologize for this late answer. Do you have an ASM profile attached to your vHost/VS? Because the default behavior of HTTP profile in LTM is to preserve client headers normally, your issue should not happen.

You can try this iRule otherwise (not tested):

```tcl
when HTTP_REQUEST {
    set HEADER1 [HTTP::header "EXAMPLE_TX_ID"]
    set HEADER2 [HTTP::header "EXAMPLE_SPAN_ID"]
}
 
when HTTP_REQUEST_SEND {
    if [string length $HEADER1] {
         HTTP::header replace "EXAMPLE_TX_ID" $HEADER1
        }
    if [string length $HEADER2] {
            HTTP::header replace "EXAMPLE_SPAN_ID" $HEADER2
        }
}

```

---

<div class="post-metadata">

**Author:** ![KeesvandenBos](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@KeesvandenBos](https://community.f5.com/u/KeesvandenBos)\
**Post date:** [June 19, 2019, 11:08am UTC](https://community.f5.com/t/irule-header-apm/47376/8 "2019-06-19T11:08:46Z")

</div>

To get the above irule to work with APM you need to add:

```tcl
when CLIENT_ACCEPTED {
    ACCESS::restrict_irule_events disable
}

```

The APM has it’s own HTTP server and bypasses the LTM HTTP server.

Cheers,

Kees

---

<div class="post-metadata">

**Author:** ![Jean\_Mamène](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@Jean\_Mamène](https://community.f5.com/u/Jean_Mam%C3%A8ne)\
**Post date:** [June 19, 2019, 2:44pm UTC](https://community.f5.com/t/irule-header-apm/47376/9 "2019-06-19T14:44:38Z")

</div>

Thank you Nicolas & Kees for your return.

the http profil i’m use is http-xff. I adapted your irule to force the insertion of the header and it works.

when I try to apply the irule to the vhost with your code in addition i can’t apply it : 01070394:3: ACCESS::restrict\_irule\_events in rule (/HorsProd/header\_APM\_test\_horsprod) requires an associated ACCESS profile on the virtual server (/HorsProd/Example\_VHOST\_443)

Regards,

---

<div class="post-metadata">

**Author:** ![KeesvandenBos](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@KeesvandenBos](https://community.f5.com/u/KeesvandenBos)\
**Post date:** [June 19, 2019, 3:36pm UTC](https://community.f5.com/t/irule-header-apm/47376/10 "2019-06-19T15:36:14Z")

</div>

Hi Jean,

So your not using APM (as stated in your subject of this question)

But good to see you got it working in the end.

Cheers,

Kees
