0

I am trying to redirect http trafic from http to https on ec2 behind a network load balancer using htaccess

# aws rule for http to https
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

Above code does not work because network loadbalancer does not add x-forwarded header.

MrWhite
  • 43,179
  • 8
  • 60
  • 84
  • Have you considered setting Application Load Balancer as a target for NLB and creating a redirect action in ALB? – Pawel Kam Feb 18 '23 at 11:17
  • Please output all the request headers that your application server sees and add this to your question. If you want to do this in `.htaccess` then there _must_ be some header that indicates the protocol the client is using (if the request to your app server itself is not over HTTPS). Or, is this there a way to _enable_ the setting of this header in the LB? – MrWhite Feb 18 '23 at 19:33

0 Answers0