728x90
반응형

리눅스 파일/디렉토리 크기별로 정렬해서 출력하기

 

du -sh * | sort -h

 

[참고사이트]
https://serverfault.com/questions/62411/how-can-i-sort-du-h-output-by-size

 

 

728x90
SMALL
Posted by gromet
728x90
반응형

(스크랩) 오픈소스 웹로그 분석 도구 , Piwik 소개 (Google Analytics 대체)

 

Piwik 은 ?

 
Piwik은 GPL 라이센스를 채용한 PHP/MySQL에서 실행할 수 있는 오픈 소스 소프트웨어로 전세계적으로 사용되는 설치형 웹사이트 로그 분석 도구 입니다.
2007 년에  Matthieu Aubry를 리더 개발자로 프로젝트가 시작하여, 현재는 45 개 이상의 언어로 번역되어 50 만개 이상의 웹 사이트에서 이용되고 있습니다.
특히 Google Analytics을 사용할 수 없는 환경에서 설치형 웹사이트 로그 분석 도구로 Piwik을 활용할 수 있습니다.
Google Analytics 보다 Piwik 이 유용한 점이 무엇인지는 아래의 자료들에서 참조할 수 있습니다.

 

Piwik 의 특징들은?

 
  • Piwik은  GPL 라이센스를 채용한 오픈 소스 소프트웨어입니다.
  • Piwik은 설치형 소프트웨어이기 때문에 직접 관리하는 데이터베이스에 데이터를 저장합니다.
    • 웹사이트를 이용하는 사용자의 정보를 외부에 저장하지않고 내부에 저장할 수 있다는 것이 Google Analytics와의 가장 큰 차이점입니다.
  • 실시간 보고서 제공
    • 물론 데이터를 수집하는데 부하가 많은 경우에는 간격을 조정해야 합니다.
    • Piwik을 사용하는 장점 중에 하나는 실시간 분석입니다. 기본값으로 10 초마다 업데이트하도록 설정되어 있습니다.
  • Tracking Code 삽입 방식
    • Google Analytics 에서 사용하는 Tracking Code 를 삽입하는 방식으로 웹사이트 이용 정보를 Piwik에 전송하도록 합니다.
    • Google Analytics 와 유사한 최신 UI를 채용
  • 다양한 플러그인 프로젝트

 

Piwik 도입 시 고려 사항

 
  • 클릭할 때 마다 DB에 기록되기 때문에 접속 건수가 많은 웹사이트의 경우에는 데이터베이스가 비대해 질수 있습니다.
    • 대규모 웹사이트의 경우 데이터베이스의 성능과 데이터 관리 등의 운영상 문제 발생할 수 있습니다.
  • 기간 별 집계 작업이 부하가 높기 때문에 특정 기간에 성능 상의 문제가 발생할 수 있습니다.
    • 집계 작업시 시스템 메모리를 높게 요구할 수 있습니다.

 

 

[참고사이트]
http://www.opennaru.com/open-source/open-soruce-web-log-analytics-piwik/

 

 

728x90
SMALL
Posted by gromet
728x90
반응형

(스크랩) 웹 서버 로그 분석도구 GoAccess

GoAccess 소개

GoAccess는 OSS기반의 실시간 웹 서버 로그 분석 도구로, xNix 계열의 터미널과 웹 브라우저를 통한 분석 화면을 제공합니다.

주요 특징은 다음과 같습니다.

  • 빠른 실시간 분석(millisecond/second) 가능 (C언어 개발)
  • 의존 라이브러리는 ncurses 뿐
  • 대부분의 웹 서버 로그 포맷 지원
    Apache, Nginx, Amazon S3, Elastic Load Balancing, CloudFront 등
  • 아름다운 터미널 화면과 Bootstrap기반의 대시보드 제공(커스트마이징 가능)
  • Valgrind 테스트 완료

GoAccess 상세기능

Teminal과 Web Dashboard에서 확인 가능한 상세기능을 설명합니다.

 

[참고사이트]
https://joypinkgom.tistory.com/34

728x90
SMALL
Posted by gromet
728x90
반응형

메일 서버 대기중인 메일 바로 발송하기 (Sendmail, Postfix flush queue)

 

가끔 쓸 일이 생기다 보니 자꾸 잊어 버린다. 한 곳에 정리해 둔다.

To flush the sendmail queue, you can use the following command:

sendmail -q

 

To flush or purge the postfix mail queue, run:
postfix flush
## OR ##
postfix -f
## OR ##
postqueue -f

Do you need to retry all messages in the deferred queue? Try:
postsuper -r ALL

To remove all mail from the queue, enter:
postsuper -d ALL

To remove all mails in the deferred queue, enter:
postsuper -d ALL deferred
728x90
SMALL
Posted by gromet
728x90
반응형

아파치 - 나쁜 봇과 크롤러를 차단

 

사용자 에이전트 목록을 보려면 아파치 로그 파일을 검색

cat /var/log/apache2/access.log |  cut -d'"' -f6 | grep -v -E -i "mozilla|chrome|safari|opera" | sort | uniq -c | sort

 

웹사이트에 액세스한 의심스러운 사용자 에이전트 목록이 표시됨

     6 GumGum-Bot/1.0 (http://gumgum.com; support@gumgum.com)
     6 PostmanRuntime/7.19.0
     6 ag_dm_spider v1.0
     7 Microsoft Office Word 2014
     32 Slackbot 1.0 (+https://api.slack.com/robots)
     33 Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots)
     38 WebexTeams
     41 www.ru
     46 facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
     57 admantx-sap/2.4 (+http://www.admantx.com/service-fetcher.html)
     72 Scrapy/2.4.1 (+https://scrapy.org)
     72 ias-sg/3.1 (+https://www.admantx.com/service-fetcher.html)
     76 WhatsApp/2.21.7.14 A
     81 Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)
     83 Clickagy Intelligence Bot v2
     85 ias-jp/3.1 (+https://www.admantx.com/service-fetcher.html)
     92 W3 Total Cache
    105 AccompanyBot
    118 rest-client/2.1.0 (linux-gnu x86_64) ruby/2.7.1p83
    141 -
    159 chimebot
    183 Mediapartners-Google
    374 ias-or/3.1 (+https://www.admantx.com/service-fetcher.html)
    686 ias-ir/3.1 (+https://www.admantx.com/service-fetcher.html)
   1930 CriteoBot/0.1 (+https://www.criteo.com/criteo-crawler/)
   2022 ias-va/3.1 (+https://www.admantx.com/service-fetcher.html)

 

 

이것으로 차단할 사용자 에이전트 목록을 만든다

GumGum-Bot
PostmanRuntime
ag_dm_spider
Scrapy
chimebot

 

 

가상호스트 설정에 추가


<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (gumgum-bot|postmanruntime|ag_dm_spider|scrapy|chimebot) [NC]
RewriteRule .* - [F,L]
</VirtualHost>

 

참고.

GitHub 프로젝트에서 나쁜 봇 및 크롤러 목록을 제공

https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.4/custom.d/globalblacklist.conf


https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.4/custom.d/globalblacklist.conf

728x90
SMALL
Posted by gromet
728x90
반응형

아파치 - 특정 쿼리 단어로 URL 차단

 

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteCond %{QUERY_STRING} (test|user|password) [NC]
RewriteRule .* - [F,L]
</VirtualHost>

 

아래와 같이 시도하면 그 아래와 같이 차단한다.


curl -I  http://www.gameking.tips?test=1
curl -I  http://www.gameking.tips?var1=user
curl -I  http://www.gameking.tips?mypassword=abcd

HTTP/1.1 403 Forbidden
Date: Sun, 18 Apr 2021 18:18:53 GMT
Server: Apache/2.4.41 (Ubuntu)
Content-Type: text/html; charset=iso-8859-1

 

HTACCESS를 사용하여 특정 쿼리 문자열로 URL 차단

 

vi /var/www/html/.htaccess

RewriteEngine On
RewriteCond %{QUERY_STRING} (test|user|password) [NC]
RewriteRule .* - [F,L]

 

참고 - https://techexpert.tips/ko/apache-ko/%ec%95%84%ed%8c%8c%ec%b9%98-%ed%8a%b9%ec%a0%95-%ec%bf%bc%eb%a6%ac-%eb%8b%a8%ec%96%b4%eb%a1%9c-url-%ec%b0%a8%eb%8b%a8/

728x90
SMALL
Posted by gromet

블로그 이미지
나는 운이 좋은 사람이다 나는 나날이 점점 더 좋아진다 내가 하는 선택과 행동은 반드시 성공으로 이어진다 내게는 인내력과 지속력이 있다 네게는 좋은것들만 모여든다
gromet

공지사항

Yesterday
Today
Total
반응형

달력

 « |  » 2024.9
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

160x600