192.168.3.222 nginx+php 略
192.168.3.22 mariadb 略
192.168.3.21 proxy_nginx
21host:安装nginx
[root@localhost conf.d]# cat /etc/nginx/proxy_params
proxy_set_header Host $http_host; //把域名也传到nginx
proxy_set_header X-Real-IP $remote_addr; //把客户端IP通过变量存放并传到nginx
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;//让nginx后端记录客户端真实地址
proxy_connect_timeout 30; //代理向后端链接超时时间
proxy_send_timeout 60; //代理等待后端响应时间
proxy_read_timeout 60; //后端代理回传超时时间
proxy_buffering on; //代理把数据放缓冲区,on(默认)
proxy_buffer_size 32k; //代理保存用户头信息缓冲区大小
proxy_buffers 4 128k; //缓冲区
---------------------------------------------------------------------------------------------------------
[root@localhost conf.d]# vim default.conf
server {
listen 80;
server_name www.le.com;
location / {
proxy_pass http://192.168.3.222:80;
include proxy_params;
}
}
-------------------------------------------------------------------------------------------------------
nginx -t
systemctl restart nginx
[root@localhost conf.d]# cat /etc/nginx/proxy_params proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 30;proxy_send_timeout 60;proxy_read_timeout 60;
proxy_buffering on;proxy_buffer_size 32k;proxy_buffers 4 128k;'
nginx log:
开启模块
192.168.3.21 - - [2020-03-15T21:10:49+08:00] "GET / HTTP/1.0" 200 43745 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36" "192.168.3.9"
关闭模块
192.168.3.21 - - [2020-03-15T21:11:23+08:00] "GET / HTTP/1.0" 200 43748 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36" "-"