Live Activity λͺ¨λν°λ§
NGINX Plus μ λ΄μ₯λ Live Activity λͺ¨λν°λ§ λμ보λμμ λλ λ€λ₯Έ λκ΅¬λ‘ JSONμ μ μ‘νμ¬ NGINX Plus λ° μ ν리μΌμ΄μ μ μ±λ₯μ μ€μκ°μΌλ‘ μΆμ ν μ μμ΅λλ€.
μ΄ λ¬Έμμμλ λνν λμ보λμ NGINX Plus REST APIμΈ NGINX Plusμμ λ°νμ λͺ¨λν°λ§ μλΉμ€λ₯Ό ꡬμ±νκ³ μ¬μ©νλ λ°©λ²μ λν΄ μ€λͺ ν©λλ€.
λͺ©μ°¨
1. Live Activity λͺ¨λν°λ§ μ 보
2. μ μ 쑰건
3. ν΅κ³μ νμν λ°μ΄ν° μμ§
4. API ꡬμ±
5. λμ보λ μ¬μ©
5-1. λμ보λμ μ‘μΈμ€
5-2. ν κ°μ
5-3. λμ보λμμ Upstream μλ² κ΄λ¦¬νκΈ°
5-4. λμ보λ μ΅μ ꡬμ±
6. REST API μ¬μ©
6-1. APIλ‘ ν΅κ³ κ°μ Έμ€κΈ°
6-2. ν΅κ³ μ¬μ€μ νκΈ°
6-3. APIλ‘ Upstream μλ² κ΄λ¦¬νκΈ°
7. OpenAPI μ¬μ
7-1. Swagger UI νμ±ννκΈ°
7-2. Swagger UI λΉνμ±ν
7-3. Swagger UI μ¬μ©
7-4. API λ° Swagger UI λΌμ΄λΈ μμ
1. Live Activity λͺ¨λν°λ§ μ 보
NGINX Plusλ μλ² μΈνλΌλ₯Ό μν λ€μν λͺ¨λν°λ§ λꡬλ₯Ό μ 곡ν©λλ€.
μλ² μΈνλΌμ μ£Όμ λΆν λ° μ±λ₯ μ§νλ₯Ό 보μ¬μ£Όλ Live Activity λͺ¨λν°λ§ μΈν°νμ΄μ€μΈ λνν λμ보λ νμ΄μ§λ NGINX Plus λ¦΄λ¦¬μ€ 9λΆν° μ¬μ©ν μ μμ΅λλ€.
νμ₯λ μν μ 보λ₯Ό μ»κ³ , ν΅κ³λ₯Ό μ¬μ€μ νκ³ , Upstream μλ²λ₯Ό μ¦μμμ κ΄λ¦¬νκ³ , Key-Value Storeλ₯Ό κ΄λ¦¬ν μ μλ μΈν°νμ΄μ€λ‘ NGINX Plus λ¦΄λ¦¬μ€ 14λΆν° μ¬μ©ν μ μλ NGINX REST API. μ΄ APIλ₯Ό μ¬μ©νλ©΄ NewRelic λλ μ체 λμ보λμ κ°μ΄ JSON μΈν°νμ΄μ€λ₯Ό μ§μνλ νμ¬ λꡬμ NGINX Plus μν μ 보λ₯Ό μ°κ²°ν μ μμ΅λλ€.
Note: NGINX Plus R14 μ΄μ μλ λμ보λμμ Upstream μλ²μ ν΅κ³ μμ§ λ° κ΄λ¦¬κ° status λ° upstream_conf λͺ¨λμ μ¬μ©νμ¬ μνλμμ΅λλ€. μ΄μ νμ₯λ status λ° upstream_conf λͺ¨λμ api λͺ¨λλ‘ λ체λ©λλ€. R16λΆν°λ status λ° upstream_conf λͺ¨λμ΄ μ κ±°λκ³ api λͺ¨λλ‘ μμ ν λ체λ©λλ€.

2. μ μ 쑰건
NGINX Plus REST API λ° λμ보λμ© NGINX Plus R14 μ΄μ λ²μ
ν΅κ³μ© λ°μ΄ν°(ν΅κ³μ νμν λ°μ΄ν° μμ§ μ°Έμ‘°)
3. ν΅κ³μ νμν λ°μ΄ν° μμ§
κ°μ μλ², Upstream μλ² κ·Έλ£Ή λλ μΊμ Zoneμμ λ°μ΄ν°λ₯Ό μμ§νλ €λ©΄ λ°μ΄ν°λ₯Ό μμ§νλ €λ κ°μ²΄μ λν΄ κ³΅μ λ©λͺ¨λ¦¬ Zoneμ μ¬μ©νλλ‘ μ€μ ν΄μΌ ν©λλ€. 곡μ λ©λͺ¨λ¦¬ Zoneμ NGINX Worker Processμμ μ°Έμ‘°νλ κ΅¬μ± λ° λ°νμ μν μ 보λ₯Ό μ μ₯ν©λλ€.
HTTPλ°TCPμλ²λ₯Ό ν΅κ³μ νμνλ €λ©΄status_zoneμ§μλ¬Έμ μ§μ ν©λλ€. μ¬λ¬serverλΈλ‘μ λμΌν Zone μ΄λ¦μ λ λ² μ΄μ μ§μ ν μ μμ΅λλ€. R19λΆν°λlocationλΈλ‘μλstatus_zoneμ§μλ¬Έμwe μ§μ ν μ μμΌλ©°, μ΄ κ²½μ° ν΅κ³λ λμ보λμμ μλ²μ μμΉμ λν΄ λ³λλ‘ μ§κ³λ©λλ€.
server {
# ...
status_zone status_page;
location / {
proxy_pass http://backend;
status_zone location_zone;
}
}
- Upstream μλ² κ·Έλ£Ήμ΄ ν΅κ³μ νμλλλ‘ νλ €λ©΄ κ°
upstreamλΈλ‘ λ³λ‘zoneμ§μλ¬Έμ μ§μ ν©λλ€.
upstream backend {
zone backend 64k;
server backend1.example.com;
server backend2.example.com;
}
- μΊμλ₯Ό ν΅κ³μ νμνλ €λ©΄ μ€μ μμ μΊμ±μ΄ νμ±νλμ΄ μλμ§ νμΈνμΈμ. μΊμ±μ μν 곡μ λ©λͺ¨λ¦¬ Zoneμ
keys_zoneλ§€κ°λ³μμproxy_cache_path,fastcgi_cache_path,scgi_cache_pathλλuwsgi_cache_pathμ§μλ¬Έμ μ§μ ν μ μμ΅λλ€.
http {
# ...
proxy_cache_path /data/nginx/cache keys_zone=one:10m;
}
- Health Checkμ ν΅κ³μ νμνλ €λ©΄
health_checkμ§μλ¬ΈμΌλ‘ Health Checkμ μ¬μ©νλλ‘ μ€μ νκ³ μλ² κ·Έλ£Ήμ΄ κ³΅μ λ©λͺ¨λ¦¬μ μλμ§ νμΈν©λλ€.
server {
# ...
status_zone status_page;
location / {
proxy_pass http://backend;
health_check;
}
}
- ν΄λ¬μ€ν° μ λ³΄κ° λμ보λμ νμλλλ‘ νλ €λ©΄ ν΄λ¬μ€ν°μ NGINX Plus μΈμ€ν΄μ€κ° ꡬμ±λμ΄ μκ³ κ° μΈμ€ν΄μ€μμ Zone λκΈ°νκ° μ¬μ© μ€μ λμ΄ μλμ§ νμΈνμΈμ.
- λμ보λμ Resolver ν΅κ³λ₯Ό νμνλ €λ©΄
resolverμ§μλ¬Έμstatus_zoneλ§€κ°λ³μλ₯Ό μ§μ ν©λλ€.
resolver 192.168.33.70 status_zone=resolver-zone1;
server {
# ...
}
- μλ£λλ©΄ κ΅¬μ± νμΌμ μ μ₯νκ³ μ’ λ£ν©λλ€.
- ꡬμ±μ ν μ€νΈνκ³ NGINX Plusλ₯Ό Reloadν©λλ€.
sudo nginx -t && sudo nginx -s reloadp
4. API ꡬμ±
APIλ₯Ό νμ±ννλ €λ©΄ λ€μκ³Ό κ°μ΄ νμΈμ.
http {
server {
# your api configuration will be here
}
}
http {
# ...
server {
listen 192.168.1.23;
# ...
location /api {
api;
# ...
}
}
}
- ν΅κ³ μΉ΄μ΄ν° μ¬μ€μ , μ¦μμμ Upstream μλ² κ΄λ¦¬ λλ Key-Value Storage κ΄λ¦¬, λμ보λμμ Upstream μλ² κ΄λ¦¬ λ± APIλ₯Ό μ¬μ©νμ¬ λ³κ²½νλ €λ©΄
apiμ§μλ¬Έμwrite=onλ§€κ°λ³μλ₯Ό μ§μ νμ¬ APIμ λν Read-Write λͺ¨λλ₯Ό μ¬μ©νλλ‘ μ€μ νμΈμ:
http {
# ...
server {
listen 192.168.1.23;
# ...
location /api {
api write=on;
# ...
}
}
}
- μλ₯Ό λ€μ΄
allowλ°denyμ§μλ¬Έμ μ¬μ©νμ¬ λ‘컬 λ€νΈμν¬μμλ§ μ‘μΈμ€λ₯Ό νμ©νλ λ± API μμΉμ λν μ‘μΈμ€λ₯Ό μ ννλ κ²μ΄ μ’μ΅λλ€.
http {
# ...
server {
listen 192.168.1.23;
# ...
location /api {
api write=on;
allow 192.168.1.0/24;
deny all;
}
}
}
- λν νΉμ μ¬μ©μμκ²λ§
PATCH,POSTλ°DELETEλ©μλμ λν μ‘μΈμ€λ₯Ό μ ννλ κ²μ΄ μ’μ΅λλ€. μ΄λ HTTP κΈ°λ³Έ μΈμ¦μ ꡬννμ¬ μνν μ μμ΅λλ€.
http {
# ...
server {
listen 192.168.1.23;
# ...
location /api {
limit_except GET {
auth_basic "NGINX Plus API";
auth_basic_user_file /path/to/passwd/file;
}
api write=on;
allow 192.168.1.0/24;
deny all;
}
}
}
/dashboard.html μμΉλ₯Ό μ§μ νμ¬ λμ보λλ₯Ό νμ±νν©λλ€. κΈ°λ³Έμ μΌλ‘ λμ보λλ root μ§μλ¬ΈμΌλ‘ μ§μ ν root λλ ν°λ¦¬(μ: /usr/share/nginx/html)μ μμ΅λλ€.
http {
# ...
server {
listen 192.168.1.23;
# ...
location /api {
limit_except GET {
auth_basic "NGINX Plus API";
auth_basic_user_file /path/to/passwd/file;
}
api write=on;
allow 192.168.1.0/24;
deny all;
}
location = /dashboard.html {
root /usr/share/nginx/html;
}
}
}
μ΅μ
μΌλ‘ OpenAPI YAML νμΌμ μ 곡λκ³ NGINX Plusμ ν¨κ» μ¬μ©λλ API μ¬μμ λν λνν λ¬Έμν λκ΅¬μΈ Swagger UIλ₯Ό μ¬μ©ν΄ λ³Ό μ μμ΅λλ€. Swagger UIμ OpenAPI YAML μ¬μμ λ€μ΄λ‘λνκ³ , ν΄λΉ νμΌμ location(μ: /swagger-ui)λ₯Ό μ§μ νκ³ , root μ§μλ¬Έμ μ¬μ©νμ¬ ν΄λΉ νμΌμ κ²½λ‘(μ: /usr/share/nginx/html)λ₯Ό μ§μ ν λ€μ, allow λ° deny μ§μλ¬Έμ μ¬μ©νμ¬ λ‘컬 λ€νΈμν¬μ λν μ‘μΈμ€λ₯Ό μ ννμΈμ.
http {
# ...
server {
listen 192.168.1.23;
# ...
location /api {
limit_except GET {
auth_basic "NGINX Plus API";
auth_basic_user_file /path/to/passwd/file;
}
api write=on;
allow 192.168.1.0/24;
deny all;
}
location = /dashboard.html {
root /usr/share/nginx/html;
}
location /swagger-ui {
add_header Content-Security-Policy "default-src 'self'";
root /usr/share/nginx/html;
allow 192.168.1.0/24;
deny all;
}
}
}
5. λμ보λ μ¬μ©
NGINX Plus λμ보λλ μλ² μΈνλΌμ μ£Όμ λΆν λ° μ±λ₯ μ§νλ₯Ό 보μ¬μ£Όλ μ€μκ° Live Activity λͺ¨λν°λ§ μΈν°νμ΄μ€λ₯Ό μ 곡ν©λλ€.
5-1. λμ보λμ μ‘μΈμ€
λΈλΌμ°μ μ μ£Όμ νμμ€μ λμ보λ νμ΄μ§μ ν΄λΉνλ μ£Όμλ₯Ό μ
λ ₯ν©λλ€(μ: http://192.168.1.23/dashboard.html). κ·Έλ¬λ©΄ root μ§μλ¬Έμ μ§μ λ λλ‘ /usr/share/nginx/htmlμ μλ λμ보λ νμ΄μ§κ° νμλ©λλ€.
λ€μ λ§ν¬μμ NGINXμ λΌμ΄λΈ λ°λͺ¨ νμ΄μ§λ νμΈν μ μμ΅λλ€.

5-2. ν κ°μ
NGINX Plus λμ보λμ λͺ¨λ μ 보λ νμΌλ‘ νμλ©λλ€.

HTTP Zones νμ Frontend μ±λ₯μ λν μμΈν ν΅κ³λ₯Ό μ 곡ν©λλ€. ν΅κ³λ http 컨ν
μ€νΈμμ κ° server, location λ° limit_req μμλ³λ‘ νμλ©λλ€. NGINX Plusκ° κ° μλ²μ λν μ 보λ₯Ό μμ§νλ €λ©΄ κ° server λλ location λΈλ‘μ status_zone μ§μλ¬Έμ ν¬ν¨ν΄μΌ ν©λλ€. limit_req μ νμ λν μ°¨νΈλ₯Ό ν¬ν¨νλ €λ©΄ limit_req_zone μ§μλ¬Έμ ꡬμ±ν΄μΌ ν©λλ€.

μ°κ²° μ ν(limit_conn)μ λν μ°¨νΈκ° μλ TCP λ° UDP μν Zoneμ΄ TCP/UDP Zones νμ νμλ©λλ€.

HTTP Upstreams νμ HTTP λ° HTTPS νΈλν½μ λν κ° Upstream κ·Έλ£Ήμ λν μ 보λ₯Ό μ 곡ν©λλ€. TCP λ° UDP Upstreams κ·Έλ£Ήμ TCP/UDP Upstreams νμ νμλ©λλ€. NGINX Plusκ° Upstream κ·Έλ£Ήμ λν μ 보λ₯Ό μμ§νλ €λ©΄ upstream κ΅¬μ± λΈλ‘μ zone μ§μλ¬Έμ μΆκ°ν΄μΌ ν©λλ€.

Caches νμ NGINX Plusμ ꡬμ±λ μΊμμ λν ν΅κ³λ₯Ό μ 곡ν©λλ€. NGINX Plusκ° Upstream κ·Έλ£Ήμ λν μ 보λ₯Ό μμ§νλ €λ©΄ μΊμλ₯Ό ꡬμ±ν΄μΌ ν©λλ€.

Shared Zones νμλ cache zone, SSL session cache, upstream zone, keyval zone, session log, sticky session, limit_conn λ° limit_req zoneμ ν¬ν¨ν κ° κ³΅μ λ©λͺ¨λ¦¬ Zoneμμ μ¬μ©νλ λ©λͺ¨λ¦¬μ μ¬μ©λμ΄ νμλ©λλ€.

Cluster νμ λͺ¨λ NGINX ν΄λ¬μ€ν° λ Έλμμ 곡μ λ©λͺ¨λ¦¬ Zoneμ λκΈ°ν μνλ₯Ό μ 곡ν©λλ€.

Resolvers νμ κ° DNS μν Zone λ³ μμ² λ° μλ΅μ λν DNS μλ² ν΅κ³λ₯Ό μ 곡ν©λλ€. NGINX Plusμμ DNS μλ²μ λν μ 보λ₯Ό μμ§νλ €λ©΄ resolver μ§μλ¬Έμ status_zone λ§€κ°λ³μλ₯Ό ν¬ν¨νμΈμ.

Workers νμ Worker Processμ λν μ 보λ₯Ό μ 곡νκ³ Workerλ³ μ°κ²° ν΅κ³λ₯Ό 보μ¬μ€λλ€.

5-3. λμ보λμμ Upstream μλ² κ΄λ¦¬νκΈ°
λμ보λ μΈν°νμ΄μ€μμ μ§μ μ μλ²λ₯Ό μΆκ°νκ±°λ Upstream μλ²λ₯Ό μμ λ° μ κ±°ν μ μμ΅λλ€. μ΄μ μ μ°κΈ° λͺ¨λμμ apiλ₯Ό νμ±νν΄μΌ νλ€λ μ μ μ μνμΈμ.
Upstreams λλ TCP/UDP Upstreams νμμ μλ² μ΄λ¦ μμ μ°ν μμ΄μ½μ ν΄λ¦νκ³ Edit selected λ° Add server λ²νΌ μ€μμ μ νν©λλ€.

Upstream μλ²λ₯Ό μΆκ°νλ €λ©΄ Add serverλ₯Ό ν΄λ¦ν©λλ€.

Upstream μλ²λ₯Ό μ κ±°νκ±°λ μμ νλ €λ©΄ κ° μλ² μ΄λ¦ μΌμͺ½μ μλ μμλ₯Ό ν΄λ¦ν λ€μ Edit selectedμ ν΄λ¦ν©λλ€.

μλ£λλ©΄ Save λ²νΌμ ν΄λ¦νμ¬ λ³κ²½ μ¬νμ μ μ₯ν©λλ€.
5-4. λμ보λ μ΅μ ꡬμ±
ν λ©λ΄μμ ν±λλ°ν΄ λ²νΌμ ν΄λ¦νμ¬ λμ보λ κ²½κ³ λ° μλ¦Όμ μκ³κ°μ ꡬμ±ν μ μμ΅λλ€.

Update every N sec – μ§μ λ μκ°(μ΄) νμ λμ보λ λ°μ΄ν°λ₯Ό μ
λ°μ΄νΈνλ©° κΈ°λ³Έκ°μ 1μ΄μ
λλ€.
4xx warnings threshold – λ HTTP Upstreamsκ³Ό HTTP Zonesμ Total μμ² μμ 4xx μ€λ₯ μ μ¬μ΄μ λΉμ¨μ λνλ
λλ€. κΈ°λ³Έκ°μ 30%μ
λλ€.
Calculate hit ratio for the past N sec – λ μΊμμ λν΄ μ§μ λ μκ°(μ΄) λ΄μ λͺ¨λ μΊμ hitλ₯Ό λνλ
λλ€. κΈ°λ³Έκ°μ 300μ΄μ
λλ€.
Not synced data threshold – ν΄λ¬μ€ν°μ λν Pending μ€μΈ λ μ½λμ Total λ μ½λ κ°μ λΉμ¨μ λνλ
λλ€. κΈ°λ³Έκ°μ 70%μ
λλ€.
Resolver errors threshold – Resolverμ λν΄ Nμ΄λ§λ€ μ
λ°μ΄νΈμ μ§μ λ μκ° νλ μ λ΄ Requestμ Resolver μ€λ₯ κ°μ λΉμ¨μ λνλ
λλ€. κΈ°λ³Έκ°μ 3%μ
λλ€.
6. REST API μ¬μ©
NGINX Plusλ₯Ό μ¬μ©νλ©΄ REST API μΈν°νμ΄μ€λ₯Ό ν΅ν΄ μλ² μΈνλΌμ ν΅κ³λ₯Ό κ΄λ¦¬ν μ μμ΅λλ€. APIλ νμ€ HTTP μμ²μ κΈ°λ°μΌλ‘ νλ©°, GET μμ²μΌλ‘ ν΅κ³λ₯Ό κ°μ Έμ€κ³ DELETE μμ²μΌλ‘ μ¬μ€μ ν μ μμ΅λλ€. Upstream μλ²λ POST μμ²μ ν΅ν΄ μΆκ°ν μ μκ³ PATCH μμ²μ ν΅ν΄ μμ ν μ μμ΅λλ€. μμΈν λ΄μ©μ APIλ‘ Upstream μλ² κ΄λ¦¬νκΈ°λ₯Ό μ°Έμ‘°νμΈμ.
μμ²μ JSON νμμΌλ‘ μ μ‘λλ©°, μ΄λ₯Ό ν΅ν΄ ν΅κ³λ₯Ό JSONμ μ§μνλ λͺ¨λν°λ§ λꡬλ λμ보λμ μ°κ²°ν μ μμ΅λλ€.
6-1. APIλ‘ ν΅κ³ κ°μ Έμ€κΈ°
μ¬λμλ‘ κ΅¬λΆλ URLμ μ¬μ©νμ¬ λͺ¨λ μμμ μν μ 보μ μ‘μΈμ€ν μ μμ΅λλ€. URLμ λ€μκ³Ό κ°μ΅λλ€.
https://demo.nginx.com/api/8/http/caches/http_cache?fields=expi
/apiλ APIμ λν NGINX κ΅¬μ± νμΌμμ ꡬμ±ν μμΉμ λλ€./8μ API λ²μ μ΄λ©°, νμ¬ API λ²μ μ 8μ λλ€./http/caches/http_cacheλ 리μμ€ κ²½λ‘μ λλ€.?.fields=expired,bypassλ μμ²λ κ°μ²΄μ μ΄λ€ νλλ₯Ό μΆλ ₯ν μ§ μ§μ νλ μ νμ μΈμμ λλ€.
μμ²λ μ 보λ JSON λ°μ΄ν° νμμΌλ‘ λ°νλ©λλ€.
μ¬μ© κ°λ₯ν λͺ¨λ rootpoint λͺ©λ‘μ κ°μ Έμ€λ €λ©΄ ν°λ―Έλμμ ‘curl’ λͺ
λ ΉμΌλ‘ GET μμ²μ 보λ΄μΈμ(μμ μμλ JSON pretty print extension “json_pp”κ° μ¬μ©λ¨).
curl -s 'https://demo.nginx.com/api/8/' | json_pp
λ°νλ JSON λ°μ΄ν°μ λλ€.
[
"nginx",
"processes",
"connections",
"slabs",
"http",
"stream",
"resolvers",
"ssl"
]
μλ₯Ό λ€μ΄ νΉμ Endpointμ λν ν΅κ³λ₯Ό μ»μΌλ €λ©΄, μ¦ NGINXμ λν μΌλ° μ 보λ₯Ό μ»μΌλ €λ©΄ λ€μ GET μμ²μ 보λ΄μΈμ.
curl -s 'https://demo.nginx.com/api/8/nginx' | json_pp
λ°νλ JSON λ°μ΄ν°μ λλ€.
{
"generation" : 14,
"timestamp" : "2021-06-28T14:04:51.515Z",
"pid" : 2201,
"address" : "206.251.255.64",
"build" : "nginx-plus-r28",
"version" : "1.23.2",
"load_timestamp" : "2022-11-29T10:00:00.114Z",
"ppid" : 92033
}
μμ² μ€μ μ νμ νλ μΈμλ₯Ό μ¬μ©νμ¬ μμ²λ κ°μ²΄μ μ΄λ€ νλλ₯Ό μΆλ ₯ν μ§ μ§μ ν μ μμ΅λλ€. μλ₯Ό λ€μ΄, NGINX Plus λ²μ κ³Ό λΉλλ§ νμνλ €λ©΄ λ€μκ³Ό κ°μ΄ λͺ λ Ήμ΄λ₯Ό μ§μ ν©λλ€.
curl -s 'https://demo.nginx.com/api/8/nginx?fields=version,build' | json_pp
λ°νλ JSON λ°μ΄ν°μ λλ€.
{
"version" : "1.23.2",
"build" : "nginx-plus-r28"
}
μ¬μ© κ°λ₯ν Endpoint λ° μ§μλλ λ°©λ²μ μ 체 λͺ©λ‘μ μ°Έμ‘° λ¬Έμλ₯Ό μ°Έμ‘°νμΈμ.
6-2. ν΅κ³ μ¬μ€μ νκΈ°
ν΅κ³ μ¬μ€μ μ DELETE λ©μλκ° ν¬ν¨λ API λͺ
λ Ήμ λμ Endpointμ μ μ‘νμ¬ μνν©λλ€. APIκ° Read-Write λͺ¨λλ‘ κ΅¬μ±λμ΄ μλμ§ νμΈνμΈμ.
λ€μκ³Ό κ°μ μ νμ ν΅κ³λ₯Ό μ¬μ€μ ν μ μμ΅λλ€.
- λΉμ μμ μΌλ‘ μ’ λ£λμλ€κ° λ€μ μμλ μμ νλ‘μΈμ€
- νμ© λ° μμ λ ν΄λΌμ΄μΈνΈ μ°κ²°
- SSL Handshake λ° μΈμ μ¬μ¬μ©
- κ° λ©λͺ¨λ¦¬ μ¬λ‘―μ λν μꡬ μ¬ν λ°
μ€ν¨μ§ν - μ΄ ν΄λΌμ΄μΈνΈ HTTP μμ²
- νΉμ HTTP μλ² μμμμ μλ½ λ° νκΈ°λ μμ², μλ΅, μμ λ° μ μ‘λ Byte
- νΉμ μΊμ Zoneμμ μΊμ μ μ€ λ° μΊμ λ―Έμ€
- Upstream μλ² κ·Έλ£Ήμ νΉμ HTTP λλ Stream Upstream μλ²μ λν ν΅κ³
μλ₯Ό λ€μ΄ λΉμ μμ μΌλ‘ μ’ λ£λμλ€κ° λ€μ μμλ μμ νλ‘μΈμ€λ₯Ό μ¬μ€μ νλ €λ©΄ ν°λ―Έλμμ curlμ ν΅ν΄ λ€μ λͺ λ Ήμ μ€ννλ©΄ λ©λλ€.
curl -X DELETE -i 'http://192.168.1.23/api/8/processes'
νμ© λ° μμ λ ν΄λΌμ΄μΈνΈ μ°κ²°μ μ¬μ€μ νλ €λ©΄ λ€μ λͺ λ Ήμ μνν©λλ€.
curl -X DELETE -i 'http://192.168.1.23/api/8/connections'
6-3. APIλ‘ Upstream μλ² κ΄λ¦¬νκΈ°
NGINX Plus REST APIλ Upstream κ·Έλ£Ήμ μλ²λ₯Ό λμ μΌλ‘ μΆκ°νκ±°λ μλ² λ§€κ°λ³μλ₯Ό μμ νκΈ° μν POST λ° PATCH HTTP λ©μλλ₯Ό μ§μν©λλ€.
Upstream κ·Έλ£Ήμ ꡬμ±μ λμ μΌλ‘ λ³κ²½νλ €λ©΄ μ μ ν API λ©μλλ₯Ό μ¬μ©νμ¬ HTTP μμ²μ 보λ΄μΈμ. λ€μ μμ μμλ curl λͺ
λ Ήμ μ¬μ©νμ§λ§, HTTP μμ²μ μν λͺ¨λ λ©μ»€λμ¦μ΄ μ§μλ©λλ€. λͺ¨λ μμ² λ³Έλ¬Έκ³Ό μλ΅μ JSON νμμ
λλ€.
URIλ λ€μ μ 보λ₯Ό μμλλ‘ μ§μ ν©λλ€.
- μμ²μ μ²λ¦¬νλ λ Έλμ νΈμ€νΈ λͺ λλ IP μ£Όμ(λ€μ μμμμλ 192.168.1.23)
- API μ§μλ¬Έμ΄ νμλλ μμΉ(api)
- API λ²μ (8)
- Upstream κ·Έλ£Ήμ μ΄λ¦, μ¬λμλ‘ κ΅¬λΆλ κ²½λ‘(http/upstreams/appservers)λ‘ νμλλ NGINX Plus κ΅¬μ± κ³μΈ΅ ꡬ쑰μμ ν΄λΉ μμΉλ₯Ό μμ±ν©λλ€.
μλ₯Ό λ€μ΄, appservers Upstream κ·Έλ£Ήμ μ μλ²λ₯Ό μΆκ°νλ €λ©΄ λ€μ curl λͺ
λ Ήμ μ μ‘ν©λλ€.
curl -X POST -d '{ \
"server": "10.0.0.1:8089", \
"weight": 4, \
"max_conns": 0, \
"max_fails": 0, \
"fail_timeout": "10s", \
"slow_start": "10s", \
"backup": true, \
"down": true \
}' -s 'http://192.168.1.23/api/8/http/upstreams/appservers/servers'
Upstream κ·Έλ£Ήμμ μλ²λ₯Ό μ κ±°νλ €λ©΄ λ€μκ³Ό κ°μ΄ νμΈμ.
curl -X DELETE -s 'http://192.168.1.23/api/8/http/upstreams/appservers/servers/0'
κ·Έλ£Ήμ 첫 λ²μ§Έ μλ²(ID 0)μ λν down λ§€κ°λ³μλ₯Ό μ€μ νλ €λ©΄ λ€μκ³Ό κ°μ΄ νμΈμ.
curl -X PATCH -d '{ "down": true }' -s 'http://192.168.1.23/api/8/http/upstreams/appservers/servers/0'
7. OpenAPI μ¬μ
NGINX Plusλ₯Ό μ¬μ©νλ©΄ κ·Έλν½ μ¬μ©μ μΈν°νμ΄μ€λ₯Ό ν΅ν΄ REST API μ€λͺ μλ₯Ό νμνκ³ API λͺ λ Ήμ λ³΄λΌ μ μμ΅λλ€. μ΄ μμ μ YAML νμμ NGINX Plus OpenAPI μ¬μκ³Ό Swagger UIλ₯Ό μ¬μ©νμ¬ μνν μ μμ΅λλ€.
Swagger UIμ YAML OpenAPI μ¬μμ μ£Όμ λͺ©μ μ NGINX API λͺ λ Ήμ λ¬Έμννκ³ μκ°ννλ κ²μ λλ€. 보μμμ μ΄μ λ‘ Production νκ²½μμλ μ¬μ©νμ§ μλ κ²μ΄ μ’μ΅λλ€.
NGINX Plus λ¦΄λ¦¬μ€ 25 μ΄μ μλ Swagger UIκ° NGINX Plus ν¨ν€μ§μ ν¨κ» μ 곡λμμ΅λλ€. NGINX Plus λ¦΄λ¦¬μ€ 26λΆν° OpenAPI YAML μ¬μκ³Ό Swagger UIλ μλμμ λ³λλ‘ κ²μλ©λλ€.
λλ μ μ ν YAML νμΌμ λν λ§ν¬λ₯Ό 볡μ¬νμ¬ μ νΈνλ OpenAPI v2 λꡬλ₯Ό κ°μ Έμ¬ μλ μμ΅λλ€.
7-1. Swagger UI νμ±ννκΈ°
Swagger UIλ₯Ό νμ±νν©λλ€:
1. Swagger UIλ₯Ό μ€μΉνκ³ κ΅¬μ±ν©λλ€. μ€μΉ ν¨ν€μ§ λ° μ§μΉ¨μ Swagger UI νμ΄μ§μμ νμΈν μ μμ΅λλ€.
2. μ¬μ© μ€μΈ NGINX Plus λ²μ κ³Ό μΌμΉνλ OpenAPI YAML νμΌ λ²μ μ μ ννκ³ νμΌμ λ€μ΄λ‘λν ν Swagger UI νμΌμ΄ λ€μ΄ μλ ν΄λμ λ£μ΅λλ€.
| OpenAPI YAML File/API Version | NGINX Plus Version | λ³κ²½ μ¬ν |
|---|---|---|
| OpenAPI v2 for API version 8 | NGINX Plus Releases 27, 28 | κ° HTTP Upstream λ° Stream Upstreamμ λν SSL ν΅κ³, κ° HTTP μλ² Zone λ° Stream μλ² Zoneμ λν SSL ν΅κ³, SSL Endpointμ λν νμ₯ ν΅κ³ |
| OpenAPI v2 for API version 7 | NGINX Plus Releases 25, 26 | κ° HTTP Upstream, Server Zone λ° location Zoneμ λν responsesμ codes λ°μ΄ν°κ° μΆκ°λμμ΅λλ€. |
| OpenAPI v2 for API version 6 | NGINX Plus Releases 20, 21, 22, 23, 24 | /stream/limit_conns/, /http/limit_conns/ λ° /http/limit_reqs/ λ°μ΄ν°κ° μΆκ°λμμ΅λλ€. |
| OpenAPI v2 for API version 5 | NGINX Plus Release 19 | Key-Value μμ expire λ§€κ°λ³μλ₯Ό μ€μ νκ±°λ λ³κ²½ν μ μμΌλ©°, /resolvers/ λ° /http/location_zones/ λ°μ΄ν°κ° μΆκ°λμμ΅λλ€. |
| OpenAPI v2 for API version 4 | NGINX Plus Release 18 | nginx error κ°μ²΄μ path λ° method νλκ° μ κ±°λμμ΅λλ€. μ΄λ¬ν νλλ μ΄μ API λ²μ μ κ³μ μ‘΄μ¬νμ§λ§ λΉ κ°μ νμν©λλ€. |
| OpenAPI v2 for API version 3 | NGINX Plus Releases 15, 16, 17 | /stream/zone_sync/ λ°μ΄ν°κ° μΆκ°λμμ΅λλ€. |
| OpenAPI v2 for API version 2 | NGINX Plus Release 14 | drain λ§€κ°λ³μκ° μΆκ°λμμ΅λλ€. |
| OpenAPI v2 for API version 1 | NGINX Plus Release 13 | /stream/keyvals/ λ°μ΄ν°κ° μΆκ°λμμ΅λλ€. |
3. Swagger UIμ ν¨κ» μλνλλ‘ NGINX Plusλ₯Ό ꡬμ±ν©λλ€. μλ₯Ό λ€μ΄ /swagger-ui locationλ₯Ό μμ±ν©λλ€.
location /swagger-ui {
# ...
}
4. Swagger UI νμΌ κ²½λ‘μ root μ§μλ¬Έμ μ¬μ©νμ¬ YAML μ¬μμ μ§μ ν©λλ€(μ: usr/share/nginx/html).
location /swagger-ui {
root /usr/share/nginx/html;
# ...
}
NGINX Plus λ¦΄λ¦¬μ€ 25 μ΄μ λ²μ μ κ²½μ° Swagger UIλ root μ§μλ¬ΈμΌλ‘ μ§μ λ root λλ ν°λ¦¬(μ: /usr/share/nginx/html)μ μμ΅λλ€.
5. allow λ° deny μ§μλ¬Έμ μ¬μ©νμ¬ λ‘컬 λ€νΈμν¬μμλ§ μ΄ μμΉμ λν μ‘μΈμ€λ₯Ό μ νν©λλ€.
location /swagger-ui {
root /usr/share/nginx/html;
allow 192.168.1.0/24;
deny all;
}
6. λν add_header μ§μλ¬Έμ μ¬μ©νμ¬ λͺ¨λ 리μμ€κ° Swagger UIμ λμΌν Originμμ λ‘λλλλ‘ μ μνλ μ½ν
μΈ λ³΄μ μ μ±
ν€λλ₯Ό νμ±ννλ κ²μ΄ μ’μ΅λλ€:
location /swagger-ui {
add_header Content-Security-Policy "default-src 'self'";
root /usr/share/nginx/html;
allow 192.168.1.0/24;
deny all;
}
7-2. Swagger UI λΉνμ±ν
NGINX Plus λ¦΄λ¦¬μ€ 25 μ΄νμμ Swagger UIλ NGINX Plus ν¨ν€μ§μ μΌλΆμ΄λ©° κΈ°λ³Έμ μΌλ‘ μ€μΉλ©λλ€. 보μμμ μ΄μ λ‘ Swagger UIμ λν μ‘μΈμ€λ₯Ό μ°¨λ¨ν μ μμ΅λλ€. μ΄λ₯Ό μν λ°©λ² μ€ νλλ /swagger-ui μμΉμ μΌμΉνλ URLμ λν μλ΅μΌλ‘ 404 μν μ½λλ₯Ό λ°ννλ κ²μ
λλ€.
location /swagger-ui {
return 404;
}
7-3. Swagger UI μ¬μ©
Swagger UI νμ΄μ§μ μ‘μΈμ€νλ €λ©΄ λ€μκ³Ό κ°μ΄ νμΈμ.
- λΈλΌμ°μ μ μ£Όμ νμμ€μ Swagger UIμ μ£Όμλ₯Ό μ
λ ₯ν©λλ€(μ΄ μμ μ£Όμλ
http://192.168.1.23/swagger-ui/).

- Swagger UI νμ΄μ§μ HTTPS νλ‘ν μ½μ ꡬμ±ν κ²½μ° ‘Schemes’ λ©λ΄μμ ‘HTTPS’ ꡬμ±νλ₯Ό μ νν΄μΌ ν©λλ€.
- μννκ³ μ νλ μμ μ ν΄λ¦ν©λλ€.
- Try it outμ ν΄λ¦ν©λλ€.
- νμν κ²½μ° νμ μ λ ₯λμ μ±μλλ€. μΌλ°μ μΌλ‘ νμ μ λ ₯λμ 곡μ λ©λͺ¨λ¦¬ Zoneμ μ΄λ¦μ λλ€.
- μ΅μ μΌλ‘ νΉμ νλλ§ νμν μ μμ΅λλ€. “Fields” μ€μ νμν νλλ₯Ό μΌνλ‘ κ΅¬λΆνμ¬ μ§μ ν©λλ€. νλλ₯Ό μ§μ νμ§ μμΌλ©΄ λͺ¨λ νλκ° νμλ©λλ€.
- Executeλ₯Ό ν΄λ¦ν©λλ€. κ²°κ³Όμ ν΄λΉ HTTP μ€λ₯ μ½λκ° Execute λͺ λ Ή μλμ νμλ©λλ€.
7-4. API λ° Swagger UI λΌμ΄λΈ μμ
NGINXλ λ°λͺ¨ μΉμ¬μ΄νΈμμ JSON λ°μ΄ν°μ Swagger UIμ λΌμ΄λΈ μμ λ₯Ό μ 곡ν©λλ€.
JSON λ°μ΄ν°μ λΌμ΄λΈ μμ λ λ€μ λ§ν¬μμ νμΈν μ μμ΅λλ€. https://demo.nginx.com/api/8/
curl λλ λΈλΌμ°μ λ₯Ό μ¬μ©νμ¬ API λͺ λ Ήμ λ³΄λΌ μ μμ΅λλ€.
curl -s 'https://demo.nginx.com/api/8/'
curl -s 'https://demo.nginx.com/api/8/nginx?fields=version,build'
curl -s 'https://demo.nginx.com/api/8/http/caches/http_cache'
curl -s 'https://demo.nginx.com/api/8/http/upstreams/'
curl -s 'https://demo.nginx.com/api/8/http/upstreams/demo-backend'
curl -s 'https://demo.nginx.com/api/8/http/upstreams/demo-backend/servers/0'
Swagger UI λ°λͺ¨ νμ΄μ§λ https://demo.nginx.com/swagger-ui/ μμ νμΈν μ μμ΅λλ€.

Live μμ λ μ½κΈ° μ μ© λͺ¨λλ‘ μλνλ©°, DELETE λ©μλλ₯Ό ν΅ν ν΅κ³ μ¬μ€μ λ° POST/PATCH λ©μλλ₯Ό ν΅ν Upstream μλ² μμ±/μμ κΈ°λ₯μ μ¬μ©ν μ μμ΅λλ€. λν λ°λͺ¨ APIλ HTTP νλ‘ν μ½μ ν΅ν΄ μ 곡λλ―λ‘ Swagger UI λ°λͺ¨ νμ΄μ§μ “Schemes” λ©λ΄μμ “HTTP” μ€ν€λ§λ₯Ό μ νν΄μΌ ν©λλ€.
λκΈμ λ¬λ €λ©΄ λ‘κ·ΈμΈν΄μΌ ν©λλ€.