How to dump HTTP request headers + source ip of the client in Nginx?

10/10/2019

Trying to troubleshoot Nginx deployed as a container. Is it possible to dump request info back to requester via webpage ?

For example, instead of standard "Welcome to Nginx!" page, could I get list of request headers and source ip of the client ?

Thank you !

Welcome to NGINX

-- Andy
containers
kubernetes
nginx

1 Answer

10/15/2019

Found image build specially for that purpose : gcr.io/google_containers/echoserver:1.4

kubectl run echoserver --image=gcr.io/google_containers/echoserver:1.4 --port=8080

vagrant@master-1:~$ curl 172.16.97.199:8080
CLIENT VALUES:
client_address=172.16.39.0
command=GET
real path=/
query=nil
request_version=1.1
request_uri=http://172.16.97.199:8080/

SERVER VALUES:
server_version=nginx: 1.10.0 - lua: 10001

HEADERS RECEIVED:
accept=*/*
host=172.16.97.199:8080
user-agent=curl/7.58.0
BODY:
-no body in request-
-- Andy
Source: StackOverflow