...
# 上面是一些基础配置就不写了
# 吧请求全部代理到 nodejs 项目
location / {
# 如果使用pm2等启动node项目,需要加header头,防止读取不到客户端IP
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
# OPTIONS 请求快速返回
if ($request_method = 'OPTIONS') {
return 204;
}
# 代理网站到所需ip和端口,不要以/结尾
proxy_pass http://xxxxxxx:6666;
}
# 吧资源设置都注释掉,因为已经经过 node 处理了
# location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
# {
# expires 30d;
# error_log /dev/null;
# access_log /dev/null;
# }
# location ~ .*\.(js|css)?$
# {
# expires 12h;
# error_log /dev/null;
# access_log /dev/null;
# }
# 如果默认的存储不够,则更改日志位置到其他硬盘
access_log /xx/xxxxx.log;
error_log /xx/xxxxx.error.log
...