Forum Discussion

EduardoSousa's avatar
EduardoSousa
Icon for Altocumulus rankAltocumulus
Aug 26, 2022

HTTP request to allow specific header

Hello guys.

I'm new to irules, I was looking for some irule that only allows a specific header to access the application, if you don't have this header allowed it will drop this connection attempt. Tried something along those lines, but VS doesn't have persistence.

when HTTP_REQUEST { if { [HTTP::header exists "Header_name"]} { persist uie [HTTP::header "Header_name"] } }

If anyone can help please? Thanks.

6 Replies

  • when HTTP_REQUEST { 
        if { ! [HTTP::header exists "Header_name"] } { 
            drop
        }
    }
  • Hi PeteWhite.

    Thanks for the help, but this irule will drop the header I want to allow. Instead of drop, it would be allow, I tried to change the drop, but it didn't work.

     

    • PeteWhite's avatar
      PeteWhite
      Icon for Employee rankEmployee

      Hi Eduardo,

      The iRule i added above will drop any HTTP requests which don't have the specified HTTP header. Is that not what you wanted?

  • Hello Pete.

    Is it possible to change the Irule to read the value and the header? For example, name = X-Custom-header and value = "ABCDEF123456"

    • PeteWhite's avatar
      PeteWhite
      Icon for Employee rankEmployee
      when HTTP_REQUEST { 
          if { (! [HTTP::header exists "Header_name"]) || ([HTTP::header value "X-Custom-header" != "ABCDEF123456) } { 
              drop
          }
      }