Welcome! Log In Create A New Profile

Advanced

Re: remote_addr variable

Francis Daly
October 25, 2020 07:22AM
On Mon, Oct 19, 2020 at 11:23:23AM +0200, A. Schulze wrote:

Hi there,

> I like to display (using ssi) if a client's remote address is ipv4 or ipv6
> Is there a variable available that indicate the current transport protocol?

I'm not aware of a ready-made variable for this; but you can probably use
"map" to make your own.

For example -- if you are happy to say that when $remote_addr includes
a : it is IPv6, otherwise it is IPv4; then at http{} level you could do
something like

map $remote_addr $this_transport_is {
~: IPv6;
default IPv4;
}

and then use $this_transport_is where you want it.

(Note: I have tested this with

return 200 "Transport: $this_transport_is\n";

but I have not tried ssi.)

> Any hint is appreciated!

Note - you may prefer to say "if $remote_addr includes a dot, it is IPv4,
else it is IPv6. And you may or may not care about listening on unix
domain sockets. Adjust the "map" to match whatever definition you like.

Good luck with it,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

remote_addr variable

A. Schulze October 19, 2020 05:26AM

Re: remote_addr variable

Francis Daly October 25, 2020 07:22AM

Re: remote_addr variable

A. Schulze October 28, 2020 01:02PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 188
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