IoT
Cara tahu user agent pengunjung pada Nginx
Saya beberapa kali membahas manipulasi Nginx berdasarkan user agent pengunjungnya dan ternyata lupa menjelaskan bagaimana caranya tahu bagaimana cara mendapatkan informasinya untuk membedakan akses setiap koneksi ke web server tidak hanya dari alamat IP. 😀 Maka, inilah tutorial singkatnya. 🙂
Sangat sederhana aslinya, kita hanya perlu mengecek catatan akses milik Nginx, lebih tepatnya file access.log
dan saya contohkan pakai tempat default berikut:
tail -20 /var/log/nginx/access.log
Kalau tidak ketemu coba cek tempat lainnya.
Nanti hasilnya akan seperti berikut:
103.76.17.99 - - [23/May/2017:04:34:05 +0000] "GET /94/melihat-memori-terpakai-linux/ HTTP/2.0" 200 9141 "https://www.google.co.id/" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36" "-" rt=0.000 ua="127.0.0.1:9000" us="200" ut="0.000" ul="35199" cs=-
66.249.69.198 - - [23/May/2017:04:34:15 +0000] "GET /184/tempat-php-ini/ HTTP/1.1" 200 8917 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" "-" rt=0.000 ua="127.0.0.1:9000" us="200" ut="0.000" ul="35238" cs=-
195.154.58.129 - - [23/May/2017:04:35:55 +0000] "GET / HTTP/1.1" 200 8477 "-" "rest-client/2.0.1 (linux-gnu x86_64) ruby/2.3.1p112" "-" rt=0.000 ua="127.0.0.1:9000" us="200" ut="0.000" ul="40105" cs=-
107.167.113.42 - - [23/May/2017:04:35:56 +0000] "GET /1058/rekomendasi-smtp-server-gratis/ HTTP/1.1" 200 24654 "-" "Opera/9.80 (Android; Opera Mini/17.0.2211/62.223; U; ms) Presto/2.12.423 Version/12.16" "183.171.183.42" rt=0.000 ua="127.0.0.1:9000" us="200" ut="0.000" ul="146893" cs=-
175.106.14.158 - - [23/May/2017:04:36:02 +0000] "GET /442/langkah-wajib-install-mysql/ HTTP/2.0" 200 10170 "https://www.google.co.id/" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/58.0.3029.110 Chrome/58.0.3029.110 Safari/537.36" "-" rt=0.000 ua="127.0.0.1:9000" us="200" ut="0.000" ul="37702" cs=-
178.33.217.66 - - [23/May/2017:04:36:04 +0000] "GET / HTTP/1.1" 200 40080 "-" "Wget/1.15 (linux-gnu)" "-" rt=0.000 ua="127.0.0.1:9000" us="200" ut="0.000" ul="40105" cs=-
139.162.228.62 - - [23/May/2017:04:36:09 +0000] "GET / HTTP/1.1" 200 8477 "-" "HetrixTools.COM Uptime Monitoring Bot. https://hetrixtools.com/uptime-monitoring-bot.html" "-" rt=0.000 ua="127.0.0.1:9000" us="200" ut="0.000" ul="40105" cs=-
114.4.21.220 - - [23/May/2017:04:36:50 +0000] "GET /1601/cara-membuat-user-linux/ HTTP/1.1" 200 11044 "https://www.google.co.id/search?hl=id&ie=UTF-8&q=cara+membuat+user+di+linux&sa=X&ved=0ahUKEwijgpz-l4XUAhXKOY8KHdABAWcQ1QIICA" "Mozilla/5.0 (Linux; U; Android 6.0; en-US; M20i Build/MRA58K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/11.3.0.950 U3/0.8.0 Mobile Safari/534.30" "-" rt=0.000 ua="127.0.0.1:9000" us="200" ut="0.000" ul="46829" cs=-
13.71.155.203 - - [23/May/2017:04:36:58 +0000] "GET / HTTP/1.1" 200 40080 "-" "Mozilla/5.0 (compatible; NIXStatsbot/1.1; +http://www.nixstats.com/bot.html)" "-" rt=0.000 ua="127.0.0.1:9000" us="200" ut="0.000" ul="40105" cs=-
103.76.21.117 - - [23/May/2017:04:37:37 +0000] "GET /36/membersihkan-disk-space-debian-ubuntu/ HTTP/2.0" 200 9179 "https://www.google.com/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0" "-" rt=0.000 ua="127.0.0.1:9000" us="200" ut="0.000" ul="35999" cs=-
Membacanya bisa pakai berbagai alat, ini file teks kok sebenarnya jadi didownload dan dibuka notepad juga bisa.