Forum Discussion

Fletcher_Cocquy's avatar
Fletcher_Cocquy
Icon for Nimbostratus rankNimbostratus
Mar 19, 2010

x-forwarded-host

Hi, we have our BigIP adding the x-forwarded-for header, but we have a new app with a new requirement for the x-forwarded-host header.

 

What is the recommended way to do this?

 

iRule?

 

 

If so, what would the iRule look like?

 

 

thanks

 

  • Hi Fletcher,

     

     

    If you're currently using a custom HTTP profile with the Insert X-Forwarded-For option enabled, you could add this to the Request Header to Insert field:

     

     

    x-forwarded-host: [HTTP::host]

     

     

    However, I'm not sure why the host header value would be changed by LTM unless you're using an iRule to rewrite it.

     

     

    Aaron
  • Are the "Header Insert" field entries space delimited?

     

    so if I already have GOHTTPS:1 and want to add x-forwarded-host: [HTTP::host] the final entry would be:

     

     

    GOHTTPS:1 x-forwarded-host:[HTTP::host]

     

     

    ?

     

     

    Or are they comma delimited?

     

    Is it best to put the individual entries in quotes?

     

     

    thanks
  • I don't think you can insert multiple header name/values with an HTTP profile. There's probably a request for enhancement to support this. You could open a case with F5 Support to ask to have your case attached to the RFE.

    In the meantime, you can use an iRule to insert multiple HTTP headers:

      
      when HTTP_REQUEST {  
        
          Insert GOHTTPS and x-forwarded-host with corresponding values  
         HTTP::header insert GOHTTPS 1 x-forwarded-host [HTTP::host]  
      }  
      

    Aaron
  • Hi, I did not want to combine the GOHTTPS with the x-forwarded-for - so I did:

     

     

    when HTTP_REQUEST {

     

    Insert x-forwarded-host with corresponding value

     

    HTTP::header insert x-forwarded-host [HTTP::host]

     

    }

     

     

    works great, thanks

     

  • HTTP::header insert accepts lists of header names and values, so this would insert GOHTTPS with a value of 1 and x-forwarded-host with a value of the HTTP host header value:

     

     

    HTTP::header insert GOHTTPS 1 x-forwarded-host [HTTP::host]

     

     

    Aaron