#2 jinzhu/configor:Golang 配置文件工具库
Golang 配置文件 2023-11-26Golang Configuration tool that support YAML, JSON, TOML, Shell Environment (Supports Go 1.10+)
coding in a complicated world
Golang Configuration tool that support YAML, JSON, TOML, Shell Environment (Supports Go 1.10+)
# 全局配置
user nginx;
worker_processes auto;
# 事件模块
events {
worker_connections 1024;
}
# HTTP 模块
http {
include mime.types;
# HTTP Server
server {
listen 80;
server_name example.com;
# 请求匹配
location / {
root /var/www/html;
index index.html;
}
# 静态资源
location /static/ {
alias /var/www/static/;
# 浏览器缓存 30 天
expires 30d;
add_header Cache-Control "public";
}
# 媒体文件
location /media/ {
alias /var/www/media/;
# 浏览器缓存 7 天
expires 7d;
add_header Cache-Control "public";
}
# 反向代理示例
location /api/ {
proxy_pass http://backend;
# HTTP 协议版本
proxy_http_version 1.1;
# 保留原始 Host
proxy_set_header Host $host;
# 客户端真实 IP
proxy_set_header X-Real-IP $remote_addr;
# 代理链路 IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 原始协议
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}