Nginx Configuration

aj-geddes/useful-ai-prompts/skills/nginx-configuration

作者 aj-geddes3f5182cfd739無授權條款355 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫7 個月前更新

Configure Nginx web server for high-performance reverse proxy, load balancing, SSL/TLS, caching, and API gateway functionality.

包含腳本DevOps & Cloud
AI 產生的概覽

指導設定 Nginx,用於反向代理、負載平衡、SSL/TLS、快取與 API 閘道。

功能
提供正式環境 Nginx 設定的參考指南與範例,涵蓋反向代理、負載平衡、SSL/TLS 終止、快取、壓縮、限流與 API 閘道模式。技能附帶參考文件、一支驗證腳本與一份 API 範本檔。產出是設定指引與範例設定,而非實際部署。
適用情境
適用於建置或調校 Nginx 伺服器的情境,例如反向代理後端服務、終止 TLS、負載平衡、加入快取或提供 API 閘道。也適用於強化或監控現有 Nginx 設定。
執行需求
需要可套用設定的 Nginx 環境;技能附帶一支可執行驗證腳本與一份範本檔。未說明需要憑證或網路存取。

Nginx Configuration

Table of Contents

Overview

Master Nginx configuration for production-grade web servers, reverse proxies, load balancing, SSL termination, caching, and API gateway patterns with advanced performance tuning.

When to Use

  • Reverse proxy setup
  • Load balancing between backend services
  • SSL/TLS termination
  • HTTP/2 and gRPC support
  • Caching and compression
  • Rate limiting and DDoS protection
  • URL rewriting and routing
  • API gateway functionality

Quick Start

Minimal working example:

nginx
# /etc/nginx/nginx.confuser nginx;worker_processes auto;worker_rlimit_nofile 65535;error_log /var/log/nginx/error.log warn;pid /var/run/nginx.pid;
events {    worker_connections 4096;    use epoll;    multi_accept on;}
http {    include /etc/nginx/mime.types;    default_type application/octet-stream;
    # Logging    log_format main '$remote_addr - $remote_user [$time_local] "$request" '                    '$status $body_bytes_sent "$http_referer" '                    '"$http_user_agent" "$http_x_forwarded_for"';
    log_format upstream_time '$remote_addr - $remote_user [$time_local] '                            '"$request" $status $body_bytes_sent '                            '"$http_referer" "$http_user_agent" '// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Production Nginx Configuration [blocked]Production Nginx Configuration
HTTPS Server with Load Balancing [blocked]HTTPS Server with Load Balancing
Nginx Configuration Script [blocked]Nginx Configuration Script
Nginx Monitoring Configuration [blocked]Nginx Monitoring Configuration

Best Practices

✅ DO

  • Use HTTP/2 for performance
  • Enable SSL/TLS with strong ciphers
  • Implement proper caching strategies
  • Use upstream connection pooling
  • Monitor with stub_status or prometheus
  • Rate limit to prevent abuse
  • Add security headers
  • Use least_conn load balancing
  • Keep error logs separate from access logs

❌ DON'T

  • Disable gzip compression
  • Use weak SSL ciphers
  • Cache authenticated responses
  • Allow direct access to backends
  • Ignore upstream health checks
  • Mix HTTP and HTTPS without redirect
  • Use default error pages in production
  • Cache sensitive user data

來源與署名

來源:aj-geddes/useful-ai-prompts位於skills/nginx-configuration提交3f5182c

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架