Problem scenario
You have an Nginx instance configured to be an HTTP load balancer (aka invisible landing page, pass-through distributor or reverse proxy). You want to analyze the inbound web traffic that your Nginx server is currently receiving. How do you find out how many active connections there are through the load balancer?
Solution
1. Modify the /etc/nginx/conf.d/default.conf file in the Nginx HTTP load balancer. In the server section (also known as the server block of the .conf file) and inside the braces themselves of this section create these three lines:
location /nginx_status {
stub_status on;
}
# The above will appear inside server { ... }.
2. Restart the Nginx service of the Nginx HTTP load balancer.
3. Run this command from the back-end of the OS that has Nginx: curl localhost/nginx_status
Bonus problem scenario
How do you do the above when Nginx is running in a Docker container?
Bonus solution
It is very much the same.
1. Go inside the Docker container.
2. Modify the /etc/nginx/conf.d/default.conf file
In the server {} section create these three lines:
location /nginx_status {
stub_status on;
}
3. Restart the Docker container.
4. Go inside the Docker container again.
5. Run this command from the Docker container that has Nginx: curl localhost/nginx_status
FFR
If you want to need to troubleshoot problems with your Nginx load balancer, see this link.