在lnmp安装目录/root/lnmp
下找到lnmp.conf
并编辑Nginx_Modules_Options
Nginx_Modules_Options='--with-http_realip_module'
保存后执行./upgrade.sh nginx
升级下Nginx。
找到网站配置文件,即/usr/local/nginx/conf/vhost/xx.com.conf
并编辑。在任意一个location
里加入以下参数:
set_real_ip_from 0.0.0.0/0;
real_ip_header X-Forwarded-For;
题外
proxy_pass代理配置
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
关闭防跨站
sed -i 's/^fastcgi_param PHP_ADMIN_VALUE/#fastcgi_param PHP_ADMIN_VALUE/g' /usr/local/nginx/conf/fastcgi.conf
启用被禁用的函数
sed -i 's/,system//g' /usr/local/php/etc/php.ini
sed -i 's/,proc_open//g' /usr/local/php/etc/php.ini
sed -i 's/,proc_get_status//g' /usr/local/php/etc/php.ini
评论