본문 바로가기

728x90

nginx

CentOS 7에서 NGINX의 최신 버전을 설치하는 방법 CentOS 7에서 NGINX의 최신 버전(안정 버전)을 설치하는 방법 nginx : High performance web server RHEL and derivatives : http://nginx.org/en/linux_packages.html#RHEL-CentOS 테스트 환경 운영체제 버전 정보 $ cat /etc/os-release | grep PRETTY_NAME | cut -d '"' -f 2 CentOS Linux 7 (Core) NGINX 설치 EPEL 저장소 및 YUM Utilities 패키지 설치 yum install -y epel-release yum-utils nginx.repo 파일 생성 sudo tee /etc/yum.repos.d/nginx.repo 더보기
[용어] RPS(Request Per Second) RPS(Request Per Second): 초당 접속자 수 Request Per Second(RPS)는 일정 시간 동안 수신한 요청(Request)의 총 개수를 초(second) 단위로 나눈 것으로 단위 시간당 처리할 수 있는 요청의 수를 나타내는 지표입니다. 일반적으로 웹 서버나 API 서버에서 RPS는 서비스의 성능을 측정하는 중요한 지표 중 하나입니다. 클라이언트에서 서버로 보내는 요청의 수가 많을수록 높은 RPS를 달성하기 위해서는 서버가 빠르게 요청을 처리하고 응답을 반환해야 합니다. 따라서, RPS는 서버의 성능을 측정하고 최적화하는 데 중요한 지표입니다. 예를 들어, 웹 서버에서 1초 동안 1000개의 요청을 처리했다면 해당 웹 서버의 RPS는 1000입니다. 이는 웹 서버가 1초 동안 1.. 더보기
Nginx의 액세스 로그에서 공격자 IP(attacker ip) 주소를 추출하는 방법 Nginx의 액세스 로그에서 공격자 IP(attacker ip) 주소를 추출하는 방법 tail -n 10000 access.log | awk '{print $1}' | sort | uniq -c | sort -nr | head -n 10 $ tail -n 10000 /var/log/nginx/access.log | awk '{print $1}' | sort | uniq -c | sort -nr | head -n 10 554 111.111.111.111 210 222.222.222.222 57 222.222.222.223 56 222.222.222.224 50 222.222.222.225 48 222.222.222.226 48 222.222.222.227 45 222.222.222.228 44 222.22.. 더보기
취약점을 방지하기 위한 보안 HTTP 헤더를 설정하기 취약점을 방지하기 위한 보안 HTTP 헤더를 설정하기 X-Content-Type-Options ###Apache Header set X-Content-Type-Options nosniff ###Nginx add_header X-Content-Type-Options nosniff; X-XSS-Protection ###Apache Header set X-XSS-Protection "1; mode=block" ###Nginx add_header X-XSS-Protection "1; mode=block"; X-Frame-Options ###Apache Header always append X-Frame-Options DENY ###Nginx add_header X-Frame-Options “DENY”; HTTP.. 더보기
[리눅스] NGING에서 PHP-FPM 상태를 활성화하고 모니터링하는 방법 NGING에서 PHP-FPM 상태를 활성화하고 모니터링하는 방법 nginx 설정 vim /etc/nginx/conf.d/default.conf $ vim /etc/nginx/conf.d/default.conf ... # nginx, php-fpm status location ~ ^/(status|ping)$ { fastcgi_pass unix:/run/php-fpm/php-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_index index.php; include fastcgi_params; allow 127.0.0.1; allow 10.11.0.0/16; allow 10.21.0.0/16; allow .. 더보기
[리눅스] NGINX 및 PHP-FPM access logs 설정 NGINX 및 PHP-FPM 액세스 로그 설정 nginx access logs format $ vim /etc/nginx/nginx.conf ... log_format main '$http_x_forwarded_for - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$remote_addr"' ' REQ_TIME: $request_time s - CONNECT_TIME: $upstream_connect_time s - PHP-FPM_STATUS: $upstream_status'; $ nginx -t nginx: the configuration file /etc/ng.. 더보기
NGINX에서 POST 데이터를 액세스 로그에 기록하는 방법 POST 데이터를 NGINX 액세스 로그에 기록하는 방법 NGINX에서 POST 데이터를 액세스 로그에 기록하려면 log_format 디렉티브를 사용하여 로그 형식을 정의하고 $request_body 변수를 포함시키면 됩니다. 다음은 POST 데이터를 액세스 로그에 기록하는 예시입니다. 1. nginx 설정 파일 (nginx.conf 또는 사이트 구성 파일)을 엽니다. 2. http 블록 내에 있는 log_format 디렉티브를 찾습니다. 만약 log_format 디렉티브가 없다면 새로 추가해야 합니다. 3. 다음과 같이 log_format 디렉티브를 정의하고 $request_body 변수를 사용하여 POST 데이터를 포함시킵니다. http { log_format custom_log '$remote_ad.. 더보기
nginx에서 limit_conn 및 limit_req 모듈 사용하기 nginx에서 limit_conn 및 limit_req 모듈 사용하기nginx의 limit_conn 및 limit_req 모듈은 서버의 요청을 제어하고 과도한 연결 및 요청으로부터 서버를 보호하는 데 사용됩니다. 이러한 기능을 사용하면 서버의 성능을 유지하면서 DDoS 공격 및 과도한 트래픽으로 인한 서버 과부하를 방지할 수 있습니다.limit_conn 모듈특정 클라이언트(IP)별로 동시 연결 수를 제한합니다.(클라이언트의 동시 연결 수를 제한)$ vim /etc/nginx/nginx.confhttp {... # "ddos_conn"이라는 limit zone 정의 (메모리 크기 10MB) limit_conn_zone $http_x_forwarded_for zone=ddos_conn:10m; .. 더보기

반응형