1

I am hosting a web server with linode.com and I want to view all the incoming connections that are going to my nginx web-server. I am running Ubuntu system and I can't seem to find anything like this. I don't know if nginx has something built in like this. And to go ahead and clear up some options I do not want to do would be logging them in some sort of database. Thanks for the help!

2 Answers 2

0

You should monitor the access log of nginx, all the incoming connection to web request you can see there. There is a httplogmodule that you can see if that is enabled in your configuration otherwise you can enable it. for more details of the nginx httplogmodule, see here. http://wiki.nginx.org/HttpLogModule#access_log

Access log path should be defined as follows so you can see the location of the file.

access_log /spool/logs/nginx-access.log gzip buffer=32k;

If above is the path of the access file, you can monitor via tail command.

# tail -f /spool/logs/nginx-access.log

0

I don't understand your question, do you want to log - or not?

If you don't want to log

If you just want a quick overview of connected IP's - you can use

netstat -atun | grep -E ":(80|443)" | awk '{print $5}' | cut -d: -f1 | sort -u -k1,1

If you wanted to know the number of connections by IP - you can use

netstat -atun | grep -E ":(80|443)" | awk '{print $5}' | cut -d: -f1 | sed -e '/^$/d' |sort | uniq -c | sort -n

If you want to log

You could use IP tables (the log would be /var/log/messages or /var/log/syslog)

iptables -A INPUT -p udp --dport 80 -j LOG
iptables -A INPUT -p udp --dport 443 -j LOG

You could use Nginx itself, see http://wiki.nginx.org/HttpLogModule

access_log /var/log/nginx-access.log;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .