Welcome! Log In Create A New Profile

Advanced

Nginx dynamic proxy_pass keeps redirecting to wrong domain

November 16, 2017 04:02PM
I am using the following config:

http {
server {
listen 80;

location / {
resolver 127.0.0.11;

auth_request /auth;
auth_request_set $instance $upstream_http_x_instance;

proxy_pass http://$instance;
}

location = /auth {
internal;
proxy_pass http://auth;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
}
}

I want to auth all routes (location /) to this server. It is a content
server.

The proxy_pass http://auth; call does the real authentication and is a Go
Lang server. The response in this requests sets also a header X-Instance.
Which reflects a name of a docker service, for example instance-001.

If authentication succeeds auth_request_set is set with the value of the
header X-Instance for example instance-001.

Now I want to serve content from this instance by utilizing proxy_pass
http://$instance;. Now I have read a lot about dynamic proxy_pass and what
to do, but nothing succeeds.

The problem is, when I go to http://example.com/cdn/test/test.jpg in the
browser, it redirects me to http://instance-001/cdn/test/test.jpg. Which is
ofcourse not correct. It should proxy the docker service with name
instance-001.

I have looked into proxy_redirect but for me it isn't clear how to set it
correctly. I also tries a rewrite like rewrite ^(/.*) $1 break; in location
= /auth. But still have the annoying redirect to
http://instance-001/cdn/test/test.jpg. I've been struggling with this for a
very long time now and I also can't find a solid solution.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nginx dynamic proxy_pass keeps redirecting to wrong domain

rsdrsd November 16, 2017 04:02PM

Re: Nginx dynamic proxy_pass keeps redirecting to wrong domain

Francis Daly November 16, 2017 05:58PM

Re: Nginx dynamic proxy_pass keeps redirecting to wrong domain

rsdrsd November 16, 2017 10:50PM

Re: Nginx dynamic proxy_pass keeps redirecting to wrong domain

pbooth November 16, 2017 10:56PM

Re: Nginx dynamic proxy_pass keeps redirecting to wrong domain

Francis Daly November 17, 2017 02:54AM

Re: Nginx dynamic proxy_pass keeps redirecting to wrong domain

rsdrsd November 17, 2017 08:18AM

Re: Nginx dynamic proxy_pass keeps redirecting to wrong domain

Francis Daly November 17, 2017 09:04AM

Re: Nginx dynamic proxy_pass keeps redirecting to wrong domain

rsdrsd November 18, 2017 12:54AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 303
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready