For debugging purposes, I'd like my nginx to return a simple response when I try to request a specific URL. For example:
Hello, friend! You've connected successfully! Your IP address is 1.2.3.4.
The IP address is important, otherwise I could use a static file.
In addition, I don't want to use external processes for generating the response - no (F)CGI, proxy, whatever. It should be NGINX itself, so I can test it in isolation.
So far, I haven't found a module that could do this. Is it possible?
You can do it using the below Nginx server configs
server {
listen 80 default_server;
server_name _;
location /health {
return 200 'Hi From Nginx $remote_addr';
}
}
$> curl http://127.0.0.1/health
Hi From Nginx 172.28.0.1