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 从公开仓库中收录这些内容。

举报或申请下架