概述
文章目录
- Nginx Web Server 依赖模块
- Nginx Web Server 配置
- Nginx 代理配置
- 日志查看
- 参考
主机 | 功能 |
---|---|
192.168.8.122 | Nginx 代理 |
10.10.200.176 | Web Server |
Nginx Web Server 依赖模块
# 加载 realip 模块
./configure --with-http_realip_module
Nginx Web Server 配置
[dev@hessian01 conf.d]$ cat test_proxy_pass.conf
server {
listen 12022;
server_name localhost;
# 重要配置
set_real_ip_from 192.168.8.122;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
location / {
root /home/dev/nginx_proxy_pass_test;
index index.html;
}
}
Nginx 代理配置
[dev@testbmj ~]$ cat /etc/nginx/conf.d/default.conf | grep -A5 testProxyPass
location /testProxyPass {
proxy_pass http://10.10.200.176:12022/;
proxy_set_header host "$host";
proxy_set_header X-Real-IP "$remote_addr";
proxy_set_header X-Forwarded-For "$proxy_add_x_forwarded_for";
}
日志查看
[dev@hessian01 log]$ cat access.log | sort -k 1 | uniq -w 20
10.10.196.174 - - [31/Aug/2021:00:33:10 +0800] "GET / HTTP/1.0" 200 21 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36"
10.10.200.16 - - [31/Aug/2021:00:33:21 +0800] "GET / HTTP/1.0" 200 21 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
10.10.200.176 - - [31/Aug/2021:00:08:03 +0800] "GET /index.html HTTP/1.1" 200 21 "-" "curl/7.29.0"
10.10.200.77 - - [31/Aug/2021:00:00:37 +0800] "GET /index.html HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36 Edg/92.0.902.78"
192.168.8.122 - - [31/Aug/2021:00:01:18 +0800] "GET / HTTP/1.0" 200 21 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36 Edg/92.0.902.78"
参考
- Nginx 获取真实用户 IP
- 多级代理下 Nginx 透传真实 IP
最后
以上就是妩媚鸵鸟为你收集整理的多级代理下 Nginx 透传真实 IP的全部内容,希望文章能够帮你解决多级代理下 Nginx 透传真实 IP所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复