7

I would like to add a custom header to the request at the AWS ALB level. I am doing migration of some iRules from F5 to ALB and there are lots of custom iRules written in F5 to add custom headers based on some conditions and I have to keep it like-for-like in order to perform the smoother migration.

Is it possible to do this from the AWS ALB itself?

CHash11
  • 746
  • 4
  • 14
  • 31
  • How did it go? Still unclear why you can't do this with ALB? – Marcin Jun 09 '21 at 22:13
  • @Marcin, Sorry for late reply but as you can see in the answers below, its not possible with ALB to modify the http request(i.e. add headers or url rewrite etcc..). Basically ALB does not support this feature. So there are work arounds suggested below, which I feel is overkill to achieve something that was easily supported with popular load balancers like BigIP F5.. I wish AWS supports this feature soon otherwise there is going to be these hacks in the solutions. – CHash11 Jul 05 '21 at 04:19

2 Answers2

6

As far as I know there is no way to set custom headers at the ALB level.

You can however add CloudFront as a CDN in front of it, that allows you to set custom headers, which will then be passed on to the ALB.

Maurice
  • 11,482
  • 2
  • 25
  • 45
3

Is it possible to do this from the AWS ALB itself?

Sadly its not. You could setup lambda function as your target, and proxy everything through lambda:

Client ---> ALB ---> Lambda ---> Instances

But such design has its own drawbacks.

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • thanks @Marcin would you please throw some light on how to route traffic from Lambda to Instances? – CHash11 Jul 20 '21 at 07:03
  • @CHash_Mike Basically you receive the request in the lambda (via the event) and then do the network call yourself. – Augunrik Nov 29 '22 at 06:20