I am leveraging AWS ALB & My setup is as follows :

ALB]--HTTPS--[NGINX]--HTTP--[ALB]--HTTP--[APP/NGINX]

the problem is I am using NGINX to forward X-Forwarded-Proto=https to the application through the ALB , but the ALB is stripping it down, the application needs X-Forwarded-Proto=https so that it can issue secure cookies and set STS header. We have tried setting this header in NGINX, but looks like APP ALB strips it down. and per AWS support this is by design.

there is a workaround to use a custom header to save the X-Forwarded-Proto value from the first ALB and send it along to the second ALB and that won't get strip down when it reaches the APP, can anyone advise on how to implement this on NGINX or suggest a different workaround to this problem

up vote 0 down vote accepted

From this forum link, they said that Application Load Balancer will pass the X-Forwarded-For/Proto/Port https://forums.aws.amazon.com/thread.jspa?messageID=738145.

If in your case the X-Forwarded-Proto header always getting value HTTP. Then, that's mean AWS ALB is not stripping the X-Forwarded-Proto header, instead, they will replace it. If its true that AWS ALB replace X-Forwarded-Proto, you can use custom HTTP header to pass the header in first nginx instance. Like this one

Location /{
    proxy_pass http://upstream;
    proxy_set_header X-Custom-Forwarded-Proto $http_x_forwarded_proto;
}

Hope this will help. Thanks

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.