MCP HubMCP Hub
스킬 목록으로 돌아가기

configure-reverse-proxy

pjt222
업데이트됨 2 days ago
8 조회
17
2
17
GitHub에서 보기
문서general

정보

이 Claude Skill은 개발자들이 Nginx, Traefik, ShinyProxy와 같은 도구를 사용해 리버스 프록시를 설정하는 데 도움을 줍니다. WebSocket 프록시, 라우팅 방법, SSL 종료, Docker 서비스 자동 탐색을 포함한 핵심 패턴을 다룹니다. 여러 서비스를 단일 진입점을 통해 라우팅하거나 기본적으로 TLS를 지원하지 않는 서비스에 TLS를 추가해야 할 때 사용하세요.

빠른 설치

Claude Code

추천
기본
npx skills add pjt222/agent-almanac -a claude-code
플러그인 명령대체
/plugin add https://github.com/pjt222/agent-almanac
Git 클론대체
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/configure-reverse-proxy

Claude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요

문서

Configure Reverse Proxy

Set up reverse proxy patterns for routing traffic to backend services using Nginx, Traefik, or ShinyProxy.

When to Use

  • Routing multiple services behind a single entry point
  • Proxying WebSocket connections (Shiny, Socket.IO, live reload)
  • Auto-discovering Docker services with Traefik labels
  • Path-based or host-based routing to different backends
  • Adding SSL termination to services that don't handle TLS

Inputs

  • Required: Backend services to proxy (host:port)
  • Required: Routing strategy (path-based, host-based, or both)
  • Optional: Proxy tool preference (Nginx, Traefik)
  • Optional: Domain name(s) for host-based routing
  • Optional: WebSocket endpoints to proxy

Procedure

Step 1: Choose Proxy Tool

FeatureNginxTraefik
ConfigurationStatic filesDocker labels / dynamic
Auto-discoveryNo (manual)Yes (Docker provider)
Let's EncryptVia certbotBuilt-in ACME
DashboardNo (3rd party)Built-in
WebSocketManual configAutomatic
Best forStatic config, high trafficDynamic Docker environments

Step 2: Nginx — Path-Based Routing

server {
    listen 80;

    location /api/ {
        proxy_pass http://api:8000/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location /app/ {
        proxy_pass http://webapp:3000/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location / {
        root /usr/share/nginx/html;
        try_files $uri $uri/ /index.html;
    }
}

Note: Trailing / on proxy_pass strips the location prefix. proxy_pass http://api:8000/; with location /api/ forwards /api/users as /users.

Step 3: Nginx — Host-Based Routing

server {
    listen 80;
    server_name api.example.com;

    location / {
        proxy_pass http://api:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

server {
    listen 80;
    server_name app.example.com;

    location / {
        proxy_pass http://webapp:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Step 4: Nginx — WebSocket Proxying

WebSockets require upgrade headers. Essential for Shiny, Socket.IO, and live reload:

location /ws/ {
    proxy_pass http://app:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_read_timeout 86400;
}

For Shiny apps specifically:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    location / {
        proxy_pass http://shiny:3838;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Host $host;
        proxy_read_timeout 86400;
        proxy_buffering off;
    }
}

Got: WebSocket connections establish and persist.

If fail: Check proxy_http_version 1.1 is set. Verify Upgrade and Connection headers.

Step 5: Traefik — Docker Label Auto-Discovery

docker-compose.yml:

services:
  traefik:
    image: traefik:v3.2
    command:
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "[email protected]"
      - "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
      - "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - letsencrypt:/letsencrypt

  api:
    image: myapi:latest
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.api.rule=Host(`api.example.com`)"
      - "traefik.http.routers.api.entrypoints=websecure"
      - "traefik.http.routers.api.tls.certresolver=letsencrypt"
      - "traefik.http.services.api.loadbalancer.server.port=8000"

  webapp:
    image: myapp:latest
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.webapp.rule=Host(`app.example.com`)"
      - "traefik.http.routers.webapp.entrypoints=websecure"
      - "traefik.http.routers.webapp.tls.certresolver=letsencrypt"
      - "traefik.http.services.webapp.loadbalancer.server.port=3000"

volumes:
  letsencrypt:

Got: Traefik auto-discovers services via labels, provisions SSL certificates.

Step 6: Traefik — Path-Based Routing with Labels

services:
  api:
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.api.rule=Host(`example.com`) && PathPrefix(`/api`)"
      - "traefik.http.routers.api.middlewares=strip-api"
      - "traefik.http.middlewares.strip-api.stripprefix.prefixes=/api"
      - "traefik.http.services.api.loadbalancer.server.port=8000"

Step 7: Traefik — Rate Limiting and Headers

labels:
  - "traefik.http.middlewares.ratelimit.ratelimit.average=100"
  - "traefik.http.middlewares.ratelimit.ratelimit.burst=50"
  - "traefik.http.middlewares.security.headers.stsSeconds=63072000"
  - "traefik.http.middlewares.security.headers.contentTypeNosniff=true"
  - "traefik.http.middlewares.security.headers.frameDeny=true"
  - "traefik.http.routers.app.middlewares=ratelimit,security"

Step 8: Verify Proxy Configuration

# Nginx: test config
docker compose exec nginx nginx -t

# Check routing
curl -H "Host: api.example.com" http://localhost/health

# Check WebSocket (needs wscat: npm install -g wscat)
wscat -c ws://localhost/ws/

# Traefik dashboard (if enabled)
# http://localhost:8080/dashboard/

Got: Requests route to correct backends. WebSocket upgrades succeed.

Validation

  • HTTP requests route to the correct backend based on path or host
  • WebSocket connections establish and maintain
  • SSL termination works (if configured)
  • Backend services receive correct Host, X-Real-IP, X-Forwarded-For headers
  • Traefik auto-discovers new services via labels (if using Traefik)
  • Configuration survives docker compose restart

Pitfalls

  • Trailing slash mismatch: proxy_pass http://app/ vs http://app behaves differently with path stripping in Nginx.
  • WebSocket timeout: Default proxy_read_timeout is 60s. Long-lived WebSocket connections need 86400 (24h).
  • Docker socket security: Mounting /var/run/docker.sock in Traefik gives it full Docker access. Use ro mount and consider socket proxy.
  • DNS resolution: Nginx resolves upstreams at startup. Use resolver 127.0.0.11 for Docker's internal DNS with dynamic services.
  • Missing proxy_buffering off: Shiny and SSE endpoints need proxy_buffering off for real-time streaming.

Related Skills

  • configure-nginx - detailed Nginx configuration with SSL and security headers
  • deploy-shinyproxy - ShinyProxy for containerized Shiny app hosting
  • setup-compose-stack - compose stack that uses a reverse proxy
  • configure-api-gateway - API gateway patterns with Kong and Traefik

GitHub 저장소

pjt222/agent-almanac
경로: i18n/caveman-lite/skills/configure-reverse-proxy
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

연관 스킬

railway-docs

문서

이 스킬은 Railway의 기능, 작동 방식 또는 특정 문서 URL에 대한 질문에 답하기 위해 최신 Railway 문서를 가져옵니다. 개발자들이 Railway의 공식 소스로부터 정확하고 최신 정보를 직접 받을 수 있도록 보장합니다. 사용자가 Railway의 작동 방식을 묻거나 Railway 문서를 참조할 때 사용하세요.

스킬 보기

n8n-code-python

문서

이 Claude Skill은 n8n의 Code 노드에서 Python 코드를 작성할 때 전문적인 지침을 제공하며, 특히 Python 표준 라이브러리 사용과 n8n의 특수 구문인 `_input`, `_json`, `_node` 작업에 중점을 둡니다. 이는 개발자가 n8n 내에서 Python의 제한 사항을 이해하도록 돕고, 대부분의 워크플로에는 JavaScript 사용을 권장하면서도 특정 데이터 변환 요구사항에 대한 Python 솔루션을 제안합니다.

스킬 보기

archon

문서

Archon 스킬은 REST API를 통해 RAG 기반 시맨틱 검색과 프로젝트 관리를 제공합니다. 이 스킬을 사용하여 문서 검색, 계층적 프로젝트/태스크 관리, 문서 업로드 기능을 갖춘 지식 검색을 수행할 수 있습니다. 외부 문서를 검색할 때는 다른 소스를 사용하기 전에 항상 Archon을 최우선으로 활용하세요.

스킬 보기

n8n-code-javascript

문서

이 Claude Skill은 n8n의 Code 노드에서 JavaScript 코드 작성에 대한 전문적인 지침을 제공합니다. `$input`/`$json` 변수, HTTP 헬퍼, DateTime 처리와 같은 필수적인 n8n 특정 구문을 다루며 일반적인 오류를 해결합니다. Code 노드에서 사용자 정의 JavaScript 처리가 필요한 n8n 워크플로우를 개발할 때 활용하세요.

스킬 보기