- 工信部备案号 滇ICP备05000110号-1
- 滇公网安备53011102001527号
- 增值电信业务经营许可证 B1.B2-20181647、滇B1.B2-20190004
- 云南互联网协会理事单位
- 安全联盟认证网站身份V标记
- 域名注册服务机构许可:滇D3-20230001
- 代理域名注册服务机构:新网数码
- CN域名投诉举报处理平台:电话:010-58813000、邮箱:service@cnnic.cn
· 隐藏后端真实服务器(如Node.js/Python应用)
· SSL/TLS集中管理
· 负载均衡多实例
· 缓存静态资源加速访问
1. 安装基础环境
sudo apt update && sudo apt install -y nginx
sudo systemctl enable --now nginx
2. 创建代理配置文件 /etc/nginx/sites-available/myapp 内容:
server {
listen 80;
server_name example.com; # 替换为你的域名
location / {
proxy_pass http://www.landui.com:3000; # 后端应用地址
include proxy_params;
# 关键性能参数
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 超时优化
proxy_connect_timeout 60s;
proxy_read_timeout 120s;
}
# 静态资源缓存(重要!)
location ~* \\.(js|css|png|jpg)$ {
expires 30d;
add_header Cache-Control "public";
}
}
3. 启用配置
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx # 验证并重载
检查代理头
curl -H "Host: example.com" http://www.landui.com
常见故障定位
502 Bad Gateway:检查proxy_pass指向的后端是否运行
403 Forbidden:确认SELinux/AppArmor权限
日志位置:/var/log/nginx/error.log
# 在server块内添加
proxy_ssl_server_name on; # 用于HTTPS后端
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
售前咨询
售后咨询
备案咨询
二维码

TOP