0

i have this weird issue which we need as a workaoround for an internal application limitation.

this is what I need, either from haproxy or nginx:

  • something calls http://my-server/?some=query_string
  • the server should respond with a redirect (http 301/302) to this location: http://my-other-server/?some=query_string?client_ip=ACTUAL_CLIENT_IP

could somebody provide an idea about how this might work? or even better still - the DNS reverse lookup name for the client IP?

thanks in advance! axel.

flypenguin
  • 203
  • 1
  • 2
  • 12

1 Answers1

1

You could try this:

location / {
    return 301 http://my-other-server/?client_ip=$remote_addr&$args;
}

This will assign the IP address. https://github.com/flant/nginx-http-rdns is a reverse DNS lookup module for nginx, which provides $rdns_hostname variable, which you can use instead of $remote_addr. However, you need to compile the module to your nginx to use it.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • 1
    Note that doing a DNS lookup here will increase your TTFB by the time it takes to do the lookup. It may or may not be worth doing in real time. It can always be done later. – Michael Hampton Oct 02 '20 at 00:28