Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

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

share|improve this answer
add comment

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;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.