제9장 — 설정 참조

Last Updated: 2026-12-04 09:44 Views: 2

모든 옵션의 항목별 참조(키·값·기본값·범위·예제)는 docs/options-reference.md에 있으며, 이 장은 소스 파서와 동기화된 전체 빠른 참조입니다.

9.1 파일 구성 및 형식

파일 내용
conf/wxserver.toml 메인 구성: 전역, HTTP 기본값, 업스트림, 스트림, WAF, 모듈
conf/manager.toml 콘솔 스위치, 리스너, 로그인 보호, JWT, 비밀번호 해시(0600)
conf/acme.toml ACME 정책 및 DNS 자격 증명, 0600, 마스터 전용
conf/cert.toml 인증서 색인, 사이트가 ssl.cert로 참조
conf/vhost/*.toml 사이트당 하나의 파일, http.include로 집계
conf/certs/ 인증서 및 개인 키
conf/mime.toml, conf/*_params.toml, conf/waf/ 보조 파일(MIME 테이블, 매개변수 템플릿, WAF 규칙/캐시)
  • include에는 두 가지 범위가 있습니다. 최상위 include는 조각 전체를 가져오며(http/modules 포함 가능), http = { include = [...] }는 사이트 조각을 집계합니다(조각은 servers/upstreams/map/geo/split_clients를 루트에 작성). 상대 경로는 각 include 파일을 기준으로 확인하며, 구성 디렉터리 내부의 상대 .toml 경로만 허용됩니다(절대 경로, .., 심볼릭 링크 탈출은 거부).
  • manager.toml / acme.toml은 비공개입니다. 메인 구성이나 모든 include에 manager/acme 최상위 블록이 있으면 오류입니다(include = ["*.toml"]이라도 마찬가지).
  • 저장되는 구성은 TOML 1.1 JSON 스타일 멀티라인 인라인 테이블을 사용합니다. TOML 1.0 전용 검증기는 거짓 오류를 보고할 수 있으므로 wxserver -t를 신뢰하십시오.
  • wxserver -t -c <구성>으로 검증하고, -s reload 또는 POST /api/config/reload로 핫 리로드합니다.

9.2 global 블록

키 유형/값 기본값 설명
user / group 문자열 플랫폼 기본값 워커 계정, root 거부(디버그: WXSERVER_ALLOW_ROOT=1)
worker_processes 정수 / "auto" 1 워커 수
worker_cpu_affinity "auto" / CPU ID / cpumask 바인딩 안 함 워커별 CPU 선호도(Linux)
log_cpu_affinity CPU ID 바인딩 안 함 마스터 로그 스레드 선호도(Linux)
pid 경로 run/wxserver.pid PID 파일
shared_state 경로 run/wxserver.shm(기본 활성화) 공유 상태 파일(mmap, 업스트림 DNS 캐시 포함). 빈 문자열이면 프로세스별 상태로 폴백하며, 기본 경로를 사용할 수 없으면 경고 후 폴백
shared_state_size 크기 32m 공유 상태 파일 크기(활성화 시)
log_socket 경로 run/wxserver-log.sock 다중 워커 로그 IPC 소켓
log_queue_size 줄 수, 0=동기 액세스 로그가 있으면 1024, 없으면 64 로그 큐 길이, 슬롯당 약 320B, 시작 시 고정
log_flush_interval_ms 밀리초 200 최대 플러시 간격, 생산자는 드롭 대신 블록
server_tokens bool true false는 버전을 숨깁니다(이전 "on"/"off"도 계속 허용)
graceful_timeout_sec 초 30 정상 종료 대기
error_page_root 디렉터리 내장 페이지 디렉터리 상대 file: 대상의 조회 루트/경계(server > http > global)
log_redact / log_redact_keys bool / 배열 true / [] 액세스 로그 쿼리 마스킹(password/token/secret/session/otp 등)
error_log 로그 객체 path 미설정 시 출력 없음 오류 로그. 범위 global/server/location, §9.11 참조

9.3 http 블록

키 유형/값 기본값 설명
include glob 배열 [] 사이트 조각 집계
client_max_body_size 크기, "0" 무제한 10m 본문 한도, server/location 재정의
sendfile bool true 정적 제로 카피, 평문 HTTP/1.1 정적 응답에만
static_meta_cache_ms 밀리초 0 정적 stat 캐시 TTL
http2 / http3 bool 활성화 false는 강제 해제(사이트 수준 true보다 우선), 실제 활성화는 listen의 http2/http3가 결정
ktls bool false Linux kTLS 오프로드(AES-GCM), 자동 폴백
max_header_bytes 바이트 1m 헤더 한도(431)
read_header_timeout_sec 초 30 헤더 읽기 타임아웃
idle_timeout_sec 초 75 keep-alive 유휴 타임아웃
access_log 경로/객체 미설정 = 기록 없음 전역 액세스 로그. { enabled = false }로 닫기, §9.11 참조
default_type MIME — 런타임에서 사용되지 않음, 사이트/로케이션 수준을 사용
disabled_modules 이름 [] 전역 비활성 모듈(사이트 목록과 병합)
gzip 객체 꺼짐 전역 gzip(§9.10 참조)
error_page map 404→file:4xx.html, 5xx→file:5xx.html 대상: file: / root: / link:(상속 로케이션 > 사이트 > http)
servers / upstreams / map / geo / split_clients / proxy_cache_path 배열 — §9.5–§9.7 참조

proxy_cache_path 필드: name(필수), path(설정 시 디스크 캐시, 미설정 시 메모리), max_size_mb(0 = 무제한), inactive_sec. 단일 항목 캐시 상한 16MB.

9.4 파생 변수(map / geo / split_clients)

키 설명
map { name = "$x", source = "$y", default, hostnames, entries }; 키: 정확 값, ~regex, default; 첫 번째 일치가 적용
geo { name = "$x", default, entries }; 키: CIDR / 단일 IP / default, 최장 접두 우선
split_clients { name = "$x", source = "$y", entries }; 키 "N%", source의 fnv 해시

9.5 server(사이트) 블록

키 유형/값 기본값 설명
name 문자열 — Manager/변환기가 conf/vhost/{name}.toml 파일을 선택할 때만 사용합니다. 사이트 파일에는 저장하지 않으며, 로드 시 파일 이름이 기준입니다
domain 배열, 정확/*.x/x.*/* [] "*"는 기본 사이트
listen ":80" 또는 { addr, ssl, http2, http3 } 필수 리스너 및 프로토콜 스위치
root / index 경로 / 배열 비어 있음 / ["index.html"] 사이트 루트와 인덱스 파일
default_type MIME — 사이트 수준 MIME 폴백
locations 배열 — 로케이션, §9.6 참조
ssl 객체 — §9.13 참조
error_page { "404" = "file:4xx.html" } http 수준 상속 상태 코드 → file:/root:/link: 대상
error_page_root 디렉터리 http/global 상속 사이트 수준 file: 상대 경로 루트
access_log 경로/객체 http 상속 사이트 액세스 로그. { enabled = false }로 닫기
waf 객체 전역 상속 사이트 WAF 재정의
http2 / http3 / ktls / sendfile / client_max_body_size bool / 크기 http 상속 사이트 수준 재정의
disabled_modules 배열 [] 사이트 비활성 모듈
schedule 객체 꺼짐 시간 창: timezone(IANA), open[](days/start/end), reason, status(400-599, 기본 503), page
strict_sni_host bool false Host가 SNI와 일치해야 함(아니면 421)
https_redirect bool false 평문을 https로 308
limit_rate / limit_rate_after 크기 무제한 사이트 속도 제한 및 무료 허용량
disabled bool false 임시 오프라인
rewrite 배열 [] rewrite 규칙, cond로 조건부(§9.6)

9.6 로케이션 블록

path 구문: = /exact, /prefix/, ^~ /static/(정규식 건너뜀), ~ /, ~* / 정규식, @name(내부 전용). 우선순위: 정확 > 최장 접두(^~는 정규식 건너뜀) > 순서대로 정규식 > 최장 접두.

키 유형/값 기본값 설명
type static/proxy/fastcgi/uwsgi/scgi/grpc/memcached/concat/image/nchan/upload/return/redirect/mp4/empty_gif/stub_status/외부 static 콘텐츠 핸들러
root / alias 경로 사이트 상속 alias는 로케이션 접두를 대체하며 DAV도 이를 따름
index / autoindex 배열 / bool ["index.html"] / false 인덱스(내부 리다이렉트) / 디렉터리 목록
default_type / internal MIME / bool — / false MIME 재정의 / 내부 전용 접근
try_files 배열 [] 순차 탐색, 마지막 항목 =code 또는 내부 URI, $uri/만 디렉터리 매칭
disable_symlinks bool false 문서 루트 아래 모든 심볼릭 링크 구성 요소 → 403
return { code, url | text } — 상태/리다이렉트/텍스트
error_page / access_log 사이트 수준과 동일 상속 재정의
client_max_body_size / limit_rate / limit_rate_after / sendfile 위와 동일 상속 로케이션 재정의
waf 객체 상속 로케이션 WAF 스위치

rewrite(server/location): 무조건 규칙은 [pattern, replacement, flag]를 사용하고, 조건 규칙은 cond가 있는 객체를 사용합니다. cond는 단일 테이블 또는 배열(AND)입니다. 주어는 exists/is_file/is_dir/is_exec 불리언을 가진 path, 또는 eq/ne/matches/not_matches/truthy와 선택적 ignore_case를 가진 var입니다. 플래그: last/break/redirect/permanent. flags = ["break"]는 재작성 후 이후 rewrite 규칙을 중지하고, break = true인 규칙은 URI를 변경하지 않고 중지합니다. ?가 있는 대체 문자열은 원래 쿼리를 버리고, http(s):// 대상은 외부로 리다이렉트하며, 내부 리다이렉트가 10회를 넘으면 500입니다. 기존 if 블록과 조건부 return/set/break는 제거되었습니다.

9.7 업스트림

키 유형/값 기본값 설명
name 문자열 필수 풀 이름, proxy_pass = "http://name"으로 참조
lb round_robin/least_conn/ip_hash round_robin 스케줄러
servers [{ addr, weight, max_fails, fail_timeout_sec, down }] 필수 weight 기본값 0(1로 처리)
keepalive 정수 꺼짐 유휴 연결 풀
health_check { type=http|tcp, uri, interval_sec=5, timeout_sec=3, falls=2, rises=2, expected_min_status=200 } 꺼짐 능동 헬스 체크
sticky { cookie_name, path, expires_sec } 꺼짐 세션 유지

런타임 변경: POST/PATCH/DELETE /api/upstreams/<name>/servers… (persist:true는 다시 기록).

9.8 stream 및 mail

stream(최상위, 순수 패스스루): upstreams[](name/servers); servers[]: listen(":port" 또는 { addr, udp }), protocol(tcp/udp), proxy_pass(풀/주소/$ssl_preread_server_name), return(proxy_pass와 상호 배타), ssl_preread(ClientHello에서 SNI 읽기), sni(도메인 → { proxy_pass } 라우팅), proxy_connect_timeout_sec(기본 5). TLS 종료/ 액세스 로그/연결 제한은 구현되지 않았습니다.

mail(최상위): servers[]: listen(필수), proxy_pass(필수), proxy_protocol(기본 false, 업스트림으로 PROXY v1 전송), timeout_sec(기본 60, I/O 시 갱신). name/protocol 키는 현재 무시됩니다(순수 TCP 패스스루). 업스트림 연결 실패 시 연결이 닫힙니다.

9.9 waf 블록

키 유형/값 기본값 설명
enabled bool false 사이트/로케이션 waf가 재정의 가능
engine full/fast full full = SecRule/CRS 엔진; fast = 경량 시그니처 검사(규칙 컴파일 없음)
rules [{ id, name, pattern, is_regex, caseless, targets, action, comment }] [] targets: URI/ARGS/HEADERS/BODY/COOKIE/UA/REFERER/IP; action: block/allow/log; allow는 CRS를 단락
response_rules 배열(block 전용) [] 응답 본문 검사, 적중 시 403 + X-WAF-Blocked
response_body_limit 바이트 1m 응답 검사 버퍼 상한
ip_lists(별칭 ip_blacklist/ip_whitelist) { white, black } 비어 있음 화이트리스트 허용, 블랙리스트 403
cc { enabled, window_sec=60, max_requests=600, key=ip|ip+uri|ip+ua|$var, block_sec=60, log_interval_sec=30 } 꺼짐 CC 보호, 로그 억제 창
crs bool false CRS 로드: 디스크 conf/waf/crs.toml 우선, 없으면 내장 crs-lite
rules_files / rules_text TOML 경로 / SecRule 텍스트 — wxserver-convert -from crs로 전체 CRS
paranoia_level / inbound_anomaly_threshold / outbound_anomaly_threshold 정수 1 / 5 / 4 CRS 튜닝
rule_exclusions ID 배열 [] ID로 CRS 규칙 제외
skip_unsupported_rules bool false 지원되지 않는 디렉티브 건너뛰기

사용자 정의 규칙은 CRS보다 먼저 실행되며, 사이트 규칙 ID는 1000000+, 전역은 100000+입니다. @rx 규칙은 공유 DFA 캐시(conf/waf/cache/, WXSERVER_WAF_CACHE=0은 비활성)로 미리 컴파일됩니다.

9.10 모듈 빠른 참조

키는 로케이션(또는 http/server 수준)이나 modules.<name> 아래에 두며, 전체 의미는 docs/options-reference.md를 참조하십시오.

모듈 주요 키(기본값) 비고
proxy proxy_pass(필수), proxy_set_header, proxy_hide_header, proxy_intercept_errors, proxy_redirect, proxy_next_upstream{http_codes,timeout}, proxy_next_upstream_tries, proxy_buffering_off, proxy_connect/read_timeout_sec(5⁄60), proxy_cache, proxy_cache_valid 리버스 프록시; Upgrade+Connection은 WS 터널을 활성화; 업스트림 실패 502/504는 오류 페이지를 렌더링(error_page 우선, 내장 5xx 폴백), 세부 내용은 error.log로; 호스트 이름은 마스터가 주기적으로 확인하고 워커 연결 실패 후 다시 가져옴
fastcgi fastcgi_pass(필수), fastcgi_param(s), fastcgi_params_file, fastcgi_index, fastcgi_split_path_info, fastcgi_hide_header, fastcgi_intercept_errors, fastcgi_keep_conn(false), fastcgi_keep_conn_max(1), fastcgi_keep_conn_idle_sec(15), fastcgi_*_timeout_sec(5/60/60), fastcgi_check_script(true) PHP; REQUEST_URI는 항상 원래 URI; keepalive는 기본으로 꺼져 있어 유휴 연결이 PHP-FPM pm.max_children을 고갈시키지 않음; fastcgi_pass 호스트 이름은 마스터가 5분마다 확인해 shared_state에 캐시(Unix 소켓은 DNS 우회)
uwsgi/scgi <p>_pass(필수), <p>_param, <p>_params_file, <p>_connect/read_timeout_sec(5⁄60), modifier1(0) UWSGI/SCGI 프로토콜; 호스트 이름은 마스터가 확인해 캐시
grpc grpc_pass(필수), grpc_tls, grpc_tls_server_name/ca/client_cert/client_key, grpc_*_timeout_sec(5⁄60), grpc_intercept_errors h2 패스스루; grpc-status는 트레일러로 전달; 호스트 이름은 마스터가 확인해 캐시(TLS SNI는 호스트 이름 유지)
memcached memcached_pass(필수), memcached_key($host$request_uri), memcached_content_type, 타임아웃(5⁄10) GET/HEAD만 허용; 미스 → 404; 호스트 이름은 마스터가 확인해 캐시, Unix 소켓 미지원
staticfile root/alias/index/autoindex/try_files/disable_symlinks, gzip_static/brotli_static/zstd_static, dav{methods,create_full_put_path} WebDAV RFC 4918; 사전 압축 br>zstd>gzip
rewrite rewrite[[pat,repl,flag]], 객체 + cond, set, return flag 기본값은 last
limit limit_req{rate,burst=0,key,status=503}, limit_conn{limit,key,status=503} shared_state 기본 활성화; 카운터가 기본으로 워커 간 공유
access access{rules[{action,cidr}],default=deny} 구성된 수준이 상위 수준을 대체
auth_basic auth_basic{realm,users_file,users} htpasswd 호환
auth_request auth_request{url,method=GET,timeout_ms=3000,allow_codes=[200],deny_codes=[401,403],copy_headers} 외부 인증 하위 요청
auth_jwt auth_jwt{alg=HS256,secret,key_file,jwks_uri,leeway_sec=30,claims,realm} HS256/RS256/ES256
secure_link secure_link{secret,md5_arg,expires_arg,require=true} MD5(base64url) 서명 URL
referer referer{valid,invalid_status=403} 핫링크 방지
realip realip{from,header=X-Forwarded-For,mode=recursive} recursive는 신뢰 프록시를 오른쪽에서 왼쪽으로 건너뜀
userid / browser / geoip userid{name,path,expires,domain}, browser{modern,ancient,deny_ancient}, geoip{db,on} 변수 $uid/$modern_browser/$geoip_*
headers headers{expires,add_headers,add_headers_always,set_headers,more_set_headers,more_clear_headers,more_headers,clear_headers} add는 해당 수준에서 대체; more_*는 상위 수준을 먼저 적용
security_headers security_headers{enabled,hsts,hsts_plaintext,csp,x_frame_options,referrer_policy,permissions_policy,nosniff} 기본 꺼짐; 필드별 병합
gzip/gunzip gzip{on,level=6,min_length=20,types,vary=true,proxied=true,disable,no_compression_4xx}, gunzip{on} 200/403/404만
brotli/zstd brotli{on,level=5,min_length=256}, zstd{on,level=3,min_length=256} 동적 우선순위 br>gzip>zstd
sub/addition/ssi/charset/minify sub{patterns[{search,replace}],once,types}, addition{before,after,types}, ssi{on,types,limit=8m}, charset{charset,source_charset,override_charset,charset_types}, minify{on,types,max_size=256k} 본문 처리
image_thumb image_thumb{quality=75,cache,backend,types,default_mode,water{...},watermark_text} URL !c300x200.jpg
nchan nchan{channel,mode=pubsub,buffer=16,history,max_subscribers=1024,max_message=256k,poll_timeout_sec=30,heartbeat_sec=15,cors} SSE/WS/롱 폴링
upload upload{dir=run/uploads,max_size=1g,cors} tus 1.0
mirror mirror{targets,copy_body=false} 비동기 미러링
accesslog/logsink access_log(§9.11의 객체), modules.http_logsink{protocol=udp,addr,url,format=json,timeout_ms=1000} 원격 로그 싱크
error_guard modules.http_error_guard{enabled,window_sec=60,threshold=20,block_sec=300,status=429,count_codes,count_5xx,key,whitelist} 오류율 차단
sysguard modules.http_sysguard{enabled,max_load1,min_mem_available_mb,status=503,retry_after=5} 과부하 보호

fastcgi는 기본적으로 SCRIPT_FILENAME, QUERY_STRING, REQUEST_METHOD, HTTP_*, SERVER_ADDR, REMOTE_PORT, REDIRECT_STATUS 등의 변수를 PHP에 전달합니다. Host 헤더가 없는 HTTP/2·HTTP/3 요청에서는 HTTP_HOST를 :authority에서 보완합니다. 여러 Cookie 헤더는 "; "로 병합합니다(병합하지 않으면 PHP가 첫 번째 cookie만 보게 되어 WordPress 로그인과 세션이 깨집니다).

9.11 로그 객체(error_log / access_log)

필드 유형/값 기본값 설명
path $year/$month/$day 지원 경로 미설정(출력 없음) 작업 디렉터리 기준, 절대 로그 디렉터리는 logs/를 재매핑. off/-는 거부되며 닫으려면 enabled = false 사용
level debug/info/warn/error warn error_log 전용
enabled bool true false는 이 계층의 error_log/access_log를 완전히 닫습니다(파일·stderr·sink 모두 없음). 하위 계층에서 다시 켤 수 있으며, 크로스 플랫폼에서 /dev/null을 대체합니다
console bool false error_log 전용: stderr/journal에도 추가 기록. enabled = false가 우선
max_size_mb / max_backups 정수 0 크기 로테이션 / 보관본 수
encrypt / key_file bool / 경로 false 줄 단위 AES-256-GCM(WXE1:), Manager는 읽기 시 복호화
format text/binary text binary = .wxlog(wxserver-log로 읽음)
format_template 템플릿 combined 텍스트 형식 전용
sample 정수 1 N개 요청당 한 줄

9.12 manager.toml

키 유형/값 기본값 설명
enable bool false 콘솔 활성화
listen host:port 127.0.0.1:9090 루프백이 아니면 [tls] 또는 allow_http=true 필요
tls 인증서 저장소의 { cert } 또는 { cert_file, key_file } — 콘솔 TLS
allow_cidr CIDR/단일 IP 배열 [] TCP 피어 기준 소스 화이트리스트, 미일치 시 403
trust_proxy / proxy_cidr bool / CIDR 배열 false / [] trust_proxy는 비어 있지 않은 proxy_cidr 필요(fail closed); X-Forwarded-*/Via/Forwarded가 있는 요청은 기본 거부(403)
domain 호스트 이름 [] Host 검증, 불일치 시 421
allow_http bool false 비루프백 평문 명시 허용
users [{ name, password_hash }] 첫 시작 시 admin 생성 bcrypt
jwt { secret_file=run/jwt.secret, expire_sec=86400 } — 세션 토큰
login { max_fail, window_sec, block_sec, captcha_after, captcha_ttl } — 로그인 잠금 및 CAPTCHA
totp 시스템 관리 — 2FA 상태는 run/manager-totp.json(0600), 직접 편집 금지

9.13 acme.toml 및 ssl

[certs.<name>]: domains(필수), email, challenge(auto/http/dns), directory/staging, timeout_sec=60, auto_renew=true, renew_before_days=30, check_interval_hours=12, key_type=ec256, eab_kid/eab_hmac_key, must_staple, preferred_chain, on_demand, request_timeout_sec=30(1-180), dns{provider=cloudflare|alidns|tencentcloud|route53, credentials, api_base, ttl_sec=120, propagation_timeout_sec=120, propagation_delay_sec, resolvers, proxy}.

사이트 ssl: cert(저장소 이름) 또는 cert_file/key_file, protocols (TLS1.2⁄1.3), ciphers, session_cache, client_cert_file/verify_client/ verify_depth(mTLS), prefer_server_ciphers.

9.14 변수

내장: $uri $document_uri $request_uri $args $query_string $host $server_name $http_host $http_<header> $scheme $https $server_port $request_method $server_protocol $remote_addr $client_ip $binary_remote_addr $remote_user $document_root $content_length $content_type $is_args $internal_redirect, 그리고 $arg_*, $cookie_*. 모듈 등록: $jwt_claim_*/$jwt_error, $secure_link/$secure_link_expires, $uid, $modern_browser/$ancient_browser, $geoip_*, rewrite set 및 map/geo/split_clients 파생 변수. 해석 순서: 내장 → 모듈 → 파생.

9.15 CLI 및 변환

wxserver -c <구성>            # 포그라운드에서 실행
wxserver -t -c <구성>         # 검증
wxserver -s reload|stop|quit  # 시그널 제어
wxserver -no-manager          # 콘솔 비활성화
wxserver --service install|uninstall|start|stop|restart|status
wxserver --reset-password [pwd] / --reset-totp
wxserver-convert -from auto|nginx|apache|htaccess|crs -in <file> [-out <file>] [--split-vhosts conf/vhost]
wxserver-tool htpasswd / bench / precompress / toml

wxserver-convert는 파일 모드에서 include를 확장하고, --split-vhosts는 사이트당 하나의 conf/vhost/{name}.toml을 작성합니다. .htaccess는 자동 감지되어 붙여넣기 가능한 로케이션 조각을 생성하며, 지원되지 않는 디렉티브는 경고를 출력합니다(-quiet로 억제). 도구 세부 사항은 제7장을 참조하십시오.

← Previous Article 제8장 — 모듈 Next Article → 제10장 — 문제 해결

Comments

No comments yet