Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Apache origin and header conversion to iRules

Patricio_quirog
Altocumulus
Altocumulus

I need to take this an Irule f5 can you help me with this please

<IfModule mod_headers.c>
Header edit Set-Cookie ^(.*)$ $1;SameSite=None;Secure
SetEnvIf Origin "^http(s)?://(.+\.)?tgr\.cl$" AccessControlAllowOrigin=$0
Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header set Access-Control-Allow-Credentials "true"
</IfModule>

2 REPLIES 2

JRahm
Community Manager
Community Manager

Hi @Patricio_quirog, I'm no expert on apache configs...but I think this duplicates the logic. Test for sure before rolling anything to a production environment:

when HTTP_REQUEST {
  set host [HTTP::host]
  if { $host ends_with “tgr.cl” } {
    set origin_match 1
  } else { ## what to do if it does not match? }
}
when HTTP_RESPONSE {
  if { [info exists origin_match] } {
    HTTP::header remove Access-Control-Allow-Origin
    HTTP::header remove Access-Control-Allow-Credentials
    HTTP::header insert Access-Control-Allow-Origin $host
    HTTP::header insert Access-Control-Allow-Credentials true
  }
}

thanks and  for sure put into a test enviroment first.