Nginx 프록시 패스
Nginx 리버스 프록시, `proxy_pass`로 요청 넘김.
리버스 프록시 vs 프록시 패스 차이
리버스 프록시: 역할. 클라이언트 요청 받아서 뒤 서버(NAS 앱)에 전달하는 중간 관리자. 서버 정체성. 프록시 패스: 명령어. Nginx 설정에서 '이 요청 저기로 넘겨!' 지시하는 구체적 명령어.
비유로 보면
리버스 프록시: 식당 웨이터. 손님(외부)은 웨이터(리버스 프록시)한테만 주문. 프록시 패스: 웨이터가 주방에 주문 전달하는 행위.
실제 Nginx 코드에서
server {
listen 80;
server_name myapp.com;
# 이 서버 전체가 "리버스 프록시" 역할 함.
location / {
# 여기서 실제로 요청 넘기는 명령어가 "proxy_pass"
proxy_pass http://192.168.1.129:5008;
}
}
결론: proxy_pass 설정하면 Nginx가 리버스 프록시 서버 됨.
여러 도메인 관리 시
기본 nginx.conf는 가만히 둠. sites-available에 도메인명으로 파일 작성.
location /horang/ {
proxy_pass http://127.0.0.1:5008/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
"/" 중요함.
요청이 https://ec2seoul.flaresolution.com/horang/load-order 오면
리스폰스는 http://localhost:5008/load-order로 감.
그래서 horang"/" 붙여줘야 함.
여기서 배울 것
- 리버스 프록시: 서버의 역할, 정체성.
- 프록시 패스: Nginx 설정 명령어.
- `proxy_pass`로 Nginx를 리버스 프록시 서버로 만듦.
- `location` 블록에서 `/` 붙이는 거 중요함.
원본 파일 보기 (.claude/skills/tn-nginx-proxy-pass/SKILL.md)
---
name: Nginx 프록시 패스 설정
description: This skill should be used when the user asks to set up Nginx as a reverse proxy, specifically when configuring `proxy_pass` to route requests to a backend service or internal server.
version: 1.0.0
source: /home/son/prj/resume/backup_notes_260317/notion/Tech Note/Nginx - proxy pass 2ddd7efd824b804aad89f32a8acaf0e0.md
---
# Nginx - proxy pass
### 1. 차이점 요약 (역할 vs 명령어)
- **리버스 프록시 (Reverse Proxy):** "역할(Role)"입니다.
- "나는 클라이언트의 요청을 받아서 뒤에 있는 서버(NAS의 앱)에 전달해주는 중간 관리자야."라는 **서버의 정체성**을 뜻합니다.
- **프록시 패스 (Proxy Pass):** "명령어(Action)"입니다.
- 특히 Nginx 설정에서 "이 요청을 저기로 넘겨(Pass)!"라고 지시하는 **구체적인 명령어**입니다.
### 2. 쉬운 비유
- **리버스 프록시:** 식당의 **"웨이터"**
- 손님(외부 사용자)은 주방장(앱)을 직접 만날 필요 없이 웨이터(리버스 프록시)에게만 주문하면 됩니다.
- **프록시 패스:** 웨이터가 주방에 **"주문 전달하는 행위"**
- 웨이터가 주방장에게 "이 주문(요청) 좀 처리해주세요"라고 토스하는 구체적인 행동입니다.
### 3. 실제 코드에서의 차이 (Nginx 기준)
사용자님이 작성하시게 될 Nginx 설정 파일(`nginx.conf`)을 보면 확실히 이해가 됩니다.
Nginx
```bash
server {
listen 80;
server_name myapp.com;
# 이 서버 전체가 "리버스 프록시" 역할을 하고 있습니다.
location / {
# 여기서 실제로 요청을 넘겨주는 명령어가 "proxy_pass" 입니다.
proxy_pass http://192.168.1.129:5008;
}
}
```
- **결론:** 사용자님은 **"프록시 패스(`proxy_pass`)"** 설정을 작성함으로써, Nginx를 **"리버스 프록시"** 서버로 만들게 되는 것입니다.
서버가 여러 도메인을 관리할수도 있으니,
기본 nginx.conf는 가만히 두고
sites-available에
도메인 명으로 파일 작성
proxy pass
```
location /horang/ {
proxy_pass http://127.0.0.1:5008/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
```
“/”가 중요
요청이
[https://ec2seoul.flaresolution.com/horang/load-order](https://ec2seoul.flaresolution.com/horang/load-order)
리스폰스는
http://localhost:5008/load-order
고로 저렇게 horang”/” 을 붙여줘야됨