Whatever you do, make sure not to trust data sent from the client.$_SERVER['REMOTE_ADDR']
contains
the real IP address of the connecting party. That is the most reliable value you can find.
However, they can be behind a proxy server in which case the proxy may have set the$_SERVER['HTTP_X_FORWARDED_FOR']
,
but this value is easily spoofed. For example, it can be set by someone without a proxy, or the IP can be an internal IP from the LAN behind the proxy.
This means that if you are going to save the$_SERVER['HTTP_X_FORWARDED_FOR']
,
make sure youalsosave
the$_SERVER['REMOTE_ADDR']
value.
E.g. by saving both values in different fields in your database.
worker_processes 10;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
#最大文件描述符
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include conf/mime.types;
default_type application/octet-stream;
keepalive_timeout 120;
tcp_nodelay on;
upstream www.s135.com{
server 192.168.1.2:80;
server 192.168.1.3:80;
server 192.168.1.4:80;
server 192.168.1.5:80;
}
upstream blog.s135.com {
server 192.168.1.7:8080;
server 192.168.1.7:8081;
server 192.168.1.7:8082;
}
server
{
listen 80;
server_name www.s135.com;
location / {
proxy_pass http://www.s135.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
log_format www_s135_com '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /data1/logs/www.log www_s135_com;
}
server
{
listen 80;
server_name blog.s135.com;
location / {
proxy_pass http://blog.s135.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
log_format blog_s135_com '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /data1/logs/blog.log blog_s135_com;
}
}
相关推荐
SpringBoot+VUE+Redis+nginx 网上拍卖平台源码 SpringBoot+VUE+Redis+nginx 网上拍卖平台源码 SpringBoot+VUE+Redis+nginx 网上拍卖平台源码 SpringBoot+VUE+Redis+nginx 网上拍卖平台源码 SpringBoot+...
ffmpeg+nginx+nginx-rtmp-module搭建个人直播平台。 使用说明(ffmpeg+nginx+rtmp-module已经整合,支持HTTP,具体配置查看conf/nginx.conf): 1.解压后,运行nginx_start.bat。(查看监控状态 ...
zabbix详细安装教程(linux+postgresql+nginx+zabbix)
用FFmpeg+nginx+rtmp搭建环境实现推流
fastdfs的安装手册说明+配置文件+fastdfs安装包+nginx安装包,压缩包内是自己结合网上资料整理的fastdfs的全套配置及说明,已成功安装并运行
基于ssm+shiro+redis+nginx tomcat服务器集群管理项目 基于ssm+shiro+redis+nginx tomcat服务器集群管理项目 基于ssm+shiro+redis+nginx tomcat服务器集群管理项目 基于ssm+shiro+redis+nginx tomcat服务器集群管理...
LVS+keeplived+nginx+apache搭建高可用、高性能php集群
1、基于vue+python+flask+uwsgi+nginx+mysql的外包项目网站项目源码.zip 2、该资源包括项目的全部源码,下载可以直接使用! 3、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为...
windows下 php+nginx配置详解,经整理修改测试通过,希望和大家一起分享!
lvs+nginx负载均衡,lvs+nginx负载均衡,lvs+nginx负载均衡,lvs+nginx负载均衡
liunx nodejs+nginx配置收藏版liunx nodejs+nginx配置收藏版
Tomcat+memcached+Nginx实现session共享 Tomcat+memcached+Nginx实现session共享
lvs+Keepalived+nginx高可用负载均衡搭建部署方案
1、在Windows系统下,搭建ffmpeg推流+nginx-http-flv-module直播拉流+FLV.js播放环境,所需依赖相关资源文件。 2、适合初学、研究、验证视频直播部署方案的相关技术人员。
tomcat+nginx +php整合笔记
idea openrestry+nginx+lua搭建企业级开发环境 将请求url以动态方式获取
大型电商项目实战1:Redis+Rest+Linux+Nginx+Spring+SpringMVC实现JAVA高并发秒杀系统,baidu链接,谢谢
keepalived+nginx+tomcat+redis+mysql所需的jdk包,之前csdn不让上传超过200m得只能分开上传。
-vue+python+flask+uwsgi+nginx+mysql.zip毕业设计-外包项目网站 -vue+python+flask+uwsgi+nginx+mysql.zip毕业设计-外包项目网站 -vue+python+flask+uwsgi+nginx+mysql.zip毕业设计-外包项目网站 -vue+python+flask...