0

I have an Nginx configuration that serves an AWS Kibana endpoint.

server {
    listen 0.0.0.0:80;
    location / {
    proxy_pass http://<vpc-elasticsearch-endpoint>/_plugin/kibana/;
    }
}

The problem is: when I access the Nginx URL, I'm redirected to another endpoint with a 302, (AWS cognito) which I can't access from browser.

The cognito URL looks like this : http://vpc-*****.amazonaws.com

I need to resolve the Cognito URL through Nginx itself. Maybe add another location block to resolve Cognito. So that the end user sees the original nginx endpoint that she used to access Nginx before redirected to Cognito.

How to achieve this in Nginx?

1 Answers1

0

Try to add Host header to proxy. By default nginx sets it to hostname found in proxy_pass directive.

server {
    listen 0.0.0.0:80;
    location / {
        proxy_pass http://<vpc-elasticsearch-endpoint>/_plugin/kibana/;
        proxy_set_header Host $host;
    }
}
Alexey Ten
  • 8,435
  • 1
  • 34
  • 36