본문 바로가기

반응형

nginx

C276x260 Nginx 환경에서 WordPress 설치하는 방법 Nginx 환경에서 WordPress 설치하는 방법테스트 환경OS : Ubuntu 24.04 LTSWeb : Nginx 1.28PHP : PHP-FPM 8.4WordPress 경로 : /usr/share/nginx/htmlNginx, PHP-FPM 설정PHP extensions 체크 확인php -m | grep -E 'mysqli|gd|curl|mbstring|zip|xml'PHP-FPM 소켓 확인ls /run/php/기본 Nginx 서버블록(HTTP)더보기---### 기본 서버 블록server { listen 80; server_name example.com www.example.com; return 301 https://$host$request_uri;}### HTTPS 서버 블록server {.. 더보기
C276x260 Nginx에 커스텀 헤더 추가하기 Nginx에 커스텀 헤더 추가하기(add_header 지시어)기본 개념add_header는 nginx가 클라이언트에 응답을 보낼 때 원하는 HTTP 헤더를 추가하는 설정입니다. 형식add_header [always];헤더이름 : X-Served-By값 : 문자열 혹은 nginx 변수 ($hostname, $remote_addr, $server_addr, $NODE_NAME 등)always : 4xx, 5xx 응답에도 항상 헤더를 포함할 때 사용커스텀 헤더 설정고정 문자열 방식서버 이름을 직접 지정하는 가장 단순한 방식입니다.sudo vim /etc/nginx/nginx.confhttp { include /etc/nginx/mime.types; default_type applic.. 더보기
C276x260 Nginx에서 특정 IP 주소를 차단하는 방법 Nginx에서 특정 IP 주소를 차단하는 방법Nginx에서 특정 IP 주소(예: 190.97.237.68, 203.0.113.55)를 차단하면서 해당 IP의 요청이 로그(액세스 로그 또는 에러 로그)에 기록되지 않도록 설정하려면 access_log off와 deny 지시어를 조합하여 특정 IP에 대해 로깅을 비활성화할 수 있습니다.Nginx 설정sudo vim /etc/nginx/nginx.conf### nginx.confuser nginx;worker_processes auto;error_log /var/log/nginx/error.log notice;pid /run/nginx.pid;events { worker_connections 1024;}http { include .. 더보기
C276x260 우분투 서버에 NGINX, PHP-FPM, Redis, PostgreSQL을 설치하고 연동하는 방법 우분투 서버에 NGINX, PHP-FPM, Redis, PostgreSQL을 설치하고 연동하는 방법전체 구성도NGINX ↔ PHP-FPM ↔ Redis ↔ PostgreSQL 순서로 데이터가 흐르는 구조더보기---Mermaid Live Editor(Link)graph LR web01[Web Serverweb-01192.168.0.101NGINX] app01[Application Serverapp-01192.168.0.111PHP-FPM] cache01[Cache Servercache-01192.168.0.121Redis] db01[Database Serverdb-01192.168.0.131PostgreSQL] web01 --> app01 app01 --> cache01 .. 더보기
C276x260 우분투 nginx 설치 명령어(DEBIAN_FRONTEND) 우분투 nginx 설치 명령어(DEBIAN_FRONTEND)sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nginx해당 명령어는 데비안 계열 운영체제에서 Nginx를 설치하기 위한 명령어입니다. sudo는 root 권한으로 실행하겠다는 의미이며,DEBIAN_FRONTEND=noninteractive는 데비안 계열 운영체제에서 패키지를 자동으로 설치할 때 발생할 수 있는 인터랙티브 프롬프트를 무시하고 미리 설정한 기본값으로 패키지를 설치하겠다는 의미입니다.apt-get은 패키지 관리자로,install은 패키지를 설치하는 명령어입니다.-y 옵션은 설치할 때 물어보는 모든 질문에 yes를 자동으로 입력하겠다는 의미이며,nginx는 설치할 패키지 이름입니다. .. 더보기
C276x260 우분투 24.04에서 Nginx 1.28과 PHP 8.3을 설치하는 방법 우분투 24.04에서 Nginx 1.28과 PHP 8.3을 설치하는 방법테스트 환경$ lsb_release -dDescription: Ubuntu 24.04.1 LTSNginx 설치필수 구성 요소 설치sudo apt updatesudo apt install -y curl gnupg2 ca-certificates lsb-release ubuntu-keyringNginx 저장소 추가curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor \ | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/nullecho "deb [signed-by=/usr/share/keyrings/n.. 더보기
C276x260 Nginx에서 URL 재작성 규칙을 설정하는 방법 Nginx에서 URL 재작성(Rewrite) 규칙을 설정하는 방법Rewrite 규칙을 설정에는 rewrite 지시어와 try_files 지시어를 사용합니다. 1. 특정 URL을 다른 URL로 리디렉션 (301/302 리다이렉트)location /old-page { return 301 https://example.com/new-page;}/old-page로 접근하면 /new-page로 영구 리디렉션(301)됨302 리다이렉트를 하려면 return 302로 변경2. URL 패턴 변경 (rewrite 사용)location /blog { rewrite ^/blog/(.*)$ /articles/$1 break;}/blog/some-post → /articles/some-post로 변경break는 해당 .. 더보기
C276x260 Nginx와 Apache 연동하여 프록시 설정하기 Nginx와 Apache 연동하여 프록시 설정하기이 구성은 Nginx를 프록시 서버로 활용하여 특정 요청(/test/)을 Apache 서버로 전달하는 방식입니다. 이를 통해 Nginx의 고성능 리버스 프록시 기능과 Apache의 웹 처리 능력을 결합하여 더욱 안정적인 웹 서비스를 제공할 수 있습니다.https://test.scbyun.comhttps://test.scbyun.com/test/테스트 환경Nginx 서버 : 192.168.10.101Apache 서버 : 192.168.10.102Nginx 설정설정 파일 위치 : /etc/nginx/conf.d/test.scbyun.com.confvim /etc/nginx/conf.d/test.scbyun.com.confupstream backend { .. 더보기

728x90
반응형