0

I am setting up a reverse proxy on Nginx, and the client request has a header X-OUTBOUND-URI, which will then hit my reverse proxy on a particular port.

I am trying to do a proxy_pass on the variable $http_x_outbound_uri, but there is a resolver error.

server {
        listen  8082;
                proxy_set_header        Host            $host;
                proxy_set_header        X-Real-IP       $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
                proxy_pass $http_x_outbound_uri;
        }
}

This is the curl command that is used: curl localhost:8082 -H "X-OUTBOUND-URI: http://localhost:9001", and I have a webserver running on port 9001.

Am I doing this wrongly? Also, for this use case, is it more suitable to do a redirect instead. Thanks.

4
  • 1
    What is stopping you from defining a resolver if you want to use proxy_pass in a way like that? Read this blog post. Commented May 23, 2022 at 9:59
  • I guess the right question is more on which is the more appropriate way to solve this problem for my use case? Because using a redirect works for me right now, but I'm not too sure if that's the right way to solve this problem. Thanks for the link, I'll read up on it! Much appreciated. Commented May 23, 2022 at 10:04
  • I don't know what is exactly your particular use case :) Probably you should read this thread first. Commented May 23, 2022 at 10:22
  • Thanks, I definitely need a reverse proxy then Commented May 23, 2022 at 15:53

1 Answer 1

1

For those who have encountered the same issue, I managed to resolve this issue by changing localhost to 127.0.0.1, otherwise, we have to set a resolver. I found the explanation in another post.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.