Nginx Plus

Nginx Plus คืออะไร

เอกสารที่เกี่ยวข้อง


คือแพ็คเก็จระดับ enterprise grade ที่มีความสามารถทุกอย่างที่ Nginx open source ทำได้ อีกทั้งยังมีฟีเจอร์หลักที่ช่วยให้ระบบมี High Availability (HA) ที่ทั้ง ปรับขยายได้ (scalable) และ เชื่อถือได้ (reliable) พร้อมเครื่องมือสำหรับ Monitoring เพื่อช่วย debug และ วิเคราะห์ปัญหา ในสถาปัตยกรรมแอปพลิเคชันที่ซับซ้อน

Advanced security ลดความเสี่ยงด้านความปลอดภัยด้วยฟีเจอร์ ดังนี้

  • request and connection limiting เพื่อป้องกันปัญหา overload, abuse, หรือ DoS attack

  • รองรับ protocol TLS1.3

  • สามารถทำ dynamic certificate loading ได้ คือความสามารถที่ NGINX Plus สามารถ โหลดหรืออัปเดต SSL/TLS certificates ได้แบบไดนามิก (ขณะรันอยู่) โดย ไม่ต้อง reload หรือ restart NGINX process

  • มีการใช้ JWT authentication

Best-of-breed support มี assistance support สำหรับการช่วยเหลือ

  • installation and deployment

  • debugging and error correction

  • security notifications

  • software updates

Load balancer ที่ชาญฉลาด

  • รองรับระบบขนาดใหญ่ (High scale) สำหรับ HTTP, TCP, UDP traffic

  • มีการรองรับ Load Balancing Algorithms ที่หลากหลาย

API gateway เป็นตัวกลางหรือ entry point ระหว่าง client กับ backend services หรือ microservices

  • มีการทำ edge gateway with TLS termination และ rate limiting

  • สามารถทำ request routing เพื่อกำหนดเส้นทาง route ของ request ว่าจะส่งไปยัง service backend ใด

  • สามารถทำ request manipulation เพื่อปรับแต่ง request/response ให้ตรงตามเงื่อนไขหรือ policy

Reverse proxy คือเซิร์ฟเวอร์กลางที่ รับ request จาก client แล้วส่งต่อไปยัง backend server

  • Session persistence

  • caching

  • multiple algorithms to maximize speed and capacity for resiliency and scale

ขั้นตอนการติดตั้ง NGINX Plus Ingress Controller บน Kubernetes ด้วย Helm

ขั้นตอนการติดตั้ง NGINX Plus Ingress Controller บน Kubernetes Cluster โดยใช้ Helm Chart และค่า config ที่จำเป็น เอกสารที่เกี่ยวข้อง


ขั้นตอนที่ 1 เตรียมข้อมูลยืนยันตัวตน (Authentication)

เริ่มต้นต้องสร้าง Kubernetes Secret เพื่อให้ Cluster สามารถยืนยันตัวตนและ pull image ของ NGINX Plus จาก Private Registry ของ NGINX ได้

  1. รับ Certificate/Key หรือ JWT Token เข้าสู่ระบบที่ my.f5.com เพื่อดาวน์โหลดไฟล์ nginx-repo.crt และ nginx-repo.key หรือคัดลอก JWT token สำหรับ Docker Registry

  2. สร้าง Kubernetes Secret: รันคำสั่ง kubectl เพื่อสร้าง docker-registry secret ใน namespace ที่ต้องการ (ตัวอย่างนี้ใช้ nginx-ingress)

kubectl create secret docker-registry nginx-repo-secret \
    --namespace nginx-ingress \
    --docker-server=private-registry.nginx.com \
    --docker-username=<your-username> \
    --docker-password=<your-password-or-jwt> \
    --docker-email=<your-email>

Note: หากยังไม่มี namespace nginx-ingress คุณสามารถสร้างก่อนด้วยคำสั่ง kubectl create namespace nginx-ingress หรือใช้ flag --create-namespace ในขั้นตอนการติดตั้ง Helm


ขั้นตอนที่ 2 เตรียมไฟล์คอนฟิกสำหรับ Helm (values.yaml)

เราจะใช้ Helm Chart อย่างเป็นทางการของ NGINX และทำการ override ค่าคอนฟิกบางส่วนเพื่อให้ชี้ไปยัง NGINX Plus

  1. เพิ่ม NGINX Helm repository: หากยังไม่เคยเพิ่ม ให้รันคำสั่งต่อไปนี้

helm repo add nginx-ingress oci://ghcr.io/nginx/charts/nginx-ingress	
  1. สร้างไฟล์ values.yaml****: สร้างไฟล์ใหม่ชื่อ values.yaml และใส่เนื้อหาดังนี้เพื่อเปิดใช้งาน NGINX Plus และระบุ Image ที่ถูกต้อง

controller:
  appprotect:
    configManager:
      image:
        repository: registry.nipa.cloud/nap/waf-config-mgr
    enforcer:
      image:
        repository: registry.nipa.cloud/nap/waf-enforcer
  config:
    entries:
      allow-snippet-annotations: "true"
      client-max-body-size: 250m
      enable-underscores-in-headers: "true"
      error-log-level: debug
      large-client-header-buffers: 4 64k
      proxy-buffers: 128 4k
      redirect-to-https: "true"
      server-name-hash-bucket-size: "1024"
      ssl-redirect: "false"
      use-forwarded-headers: "true"
      worker-processes: "40"
  customConfigMap: null
  image:
    repository: registry.nipa.cloud/nginx-ic/nginx-plus-ingress
  nginxplus: true
  customPorts:
    - name: nginx-dashboard
      containerPort: 8080
      protocol: TCP

serviceInsight:
  create: true

ขั้นตอนที่ 3 ติดตั้งด้วย Helm

เมื่อเตรียม Secret และไฟล์ values.yaml เรียบร้อยแล้ว ก็สามารถติดตั้ง NGINX Plus Ingress Controller ได้ด้วยคำสั่ง helm install

helm install nginx-ingress-my-release nginx-ingress/nginx-ingress \
  --version 2.2.1 \
  --values xxxxxxx.yaml
  • nginx-ingress-my-release คือชื่อ release ที่คุณตั้งเอง

  • nginx-ingress/nginx-ingress คือ [repo/chart]

  • --version ช่วยให้แน่ใจว่าใช้เวอร์ชันที่ต้องการ

  • --values หรือ -f ใช้กำหนดไฟล์ค่า override หลังจากรันคำสั่งนี้สำเร็จ NGINX Plus Ingress Controller จะถูกติดตั้งและพร้อมใช้งานใน Kubernetes Cluster ของคุณโดยจะได้เป็น service type loadbalancer โดย default

apiVersion: v1
kind: Service
metadata:
    name: nginx-dashboard
  namespace: nginx-ingress
spec:
  ports:
    - name: dashboard
      port: 8080
      protocol: TCP
      targetPort: 8080
  selector:
    app.kubernetes.io/name: nginx-ingress
  type: ClusterIP

Last updated

Was this helpful?