I have a redash EC2 instance running well on its public IP address. I want to place it behind an Elastic Load Balancer or CloudFront Distribution but the health check keeps failing since nginx is always returning a 302 redirect instead 200.

HTTP/1.1 302 FOUND
Server: nginx
Date: Wed, 02 Aug 2017 01:29:39 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 347
Connection: keep-alive

Have anyone tried this setup? Any idea on why is the redirect happening?

Thanks a lot in advance.

Here’s my nginx config:

upstream rd_servers {
  server 127.0.0.1:5000;
}

server {

  server_tokens off;

  listen 80 default;

  access_log /var/log/nginx/rd.access.log;

  gzip on;
  gzip_types *;
  gzip_proxied any;

  location / {
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass       http://rd_servers;
  }
}

I think the issue is with the X-Forwarded-Proto header. In my setup I use:

    proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;

Which makes sure that ELB passes the protocol it received the request on vs. $scheme which will always be HTTP.

Hello @arikfr. I am so sorry for the late reply. Could not work on this until now.

I did the change you mentioned and I am still getting the redirection:

HTTP/1.1 302 Moved Temporarily
Content-Type: text/html; charset=utf-8
Content-Length: 353
Connection: keep-alive
Date: Thu, 26 Oct 2017 00:24:29 GMT
Server: nginx 

I whitelisted the Host header in cludfront and now the cloudfront host is kept, it does not redirect to the ELB DNS, but the protocol is change to http.

Did you do any other change in your setup? Thanks a lot!

Hi,
This is because root will always redirect you to /login so there are two ways to solve this issue:

  1. Change the status code you expect to 302 instead of 200
  2. Change health check address to /login instead of /
1 Like

Hey @mehmetkemalbayer – This answer seems like exactly what I need to solve my issue.

Silly question: Where would we make these changes?

I setup the Redash AWS EC2 AMI (https://redash.io/help/open-source/setup)

Been searching around the EC2 instance to no avail