当前位置:网站首页>Realize reverse proxy client IP transparent transmission
Realize reverse proxy client IP transparent transmission
2022-07-05 23:00:00 【wwzroom】
Experimental environment :
1. modify nginx Agent profile
[[email protected]:/apps/nginx/conf.d]#
vim pc.conf
server {
listen 80;
proxy_cache off;
#proxy_cache proxycache;
#proxy_cache_key $request_uri;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 302 301 10m;
proxy_cache_valid any 5m;
add_header class M44;
add_header X-Via $server_addr;
add_header X-Cache $upstream_cache_status;
add_header X-Accel $server_name;
proxy_hide_header ETag;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Add client IP And reverse proxy IP To request message header
#listen 443 ssl;
#ssl_certificate /apps/nginx/conf.d/ssl/www.magedu.org.crt;
#ssl_certificate_key /apps/nginx/conf.d/ssl/www.magedu.org.key;
#ssl_session_cache shared:sslcache:20m;
#ssl_session_timeout 10m;
server_name www.magedu.org;
root /data/nginx/html/pc/;
location / {
root /data/nginx/html/pc/;
}
location /api {
proxy_pass http://10.0.0.8:8080/;
}
location ~* \.(jpe?g|png|bmp|gif)$ {
# Implement reverse proxy
proxy_pass http://10.0.0.28;
}
}
[[email protected]:/apps/nginx/conf.d]#
nginx -s reload
2. Add rules for viewing headers to the backend server logs . add to \"%{
X-Real-IP}i\"
[[email protected]:~]#
vim /etc/httpd/conf/httpd.conf
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-forwarded-for}i\" " combined
[[email protected]:~]#
systemctl restart httpd
3. Client to test
[[email protected] ~]#curl www.magedu.org/16m.jpg -I
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 03 Jul 2022 01:50:18 GMT
Content-Type: image/jpeg
Content-Length: 16422438
Connection: keep-alive
Last-Modified: Sat, 02 Jul 2022 07:16:41 GMT
Accept-Ranges: bytes
class: M44
X-Via: 10.0.0.58
X-Accel: www.magedu.org
4.web Server production log
[[email protected]:~]#
tail -f /var/log/httpd/access_log
10.0.0.58 - - [03/Jul/2022:09:54:23 +0800] "HEAD /16m.jpg HTTP/1.0" 200 - "-" "curl/7.58.0" "10.0.0.100"
# Realization ip Address transmission .
边栏推荐
- The difference between MVVM and MVC
- EasyCVR集群部署如何解决项目中的海量视频接入与大并发需求?
- Business introduction of Zhengda international futures company
- TypeError: this. getOptions is not a function
- npm ELECTRON_ Mirror is set as domestic source (npmmirror China mirror)
- Binary tree (III) -- heap sort optimization, top k problem
- Function default parameters, function placeholder parameters, function overloading and precautions
- Starting from 1.5, build a micro Service Framework -- log tracking traceid
- Common JVM tools and optimization strategies
- Thinkphp5.1 cross domain problem solving
猜你喜欢
Finally understand what dynamic planning is
Common JVM tools and optimization strategies
Metaverse ape ape community was invited to attend the 2022 Guangdong Hong Kong Macao Great Bay metauniverse and Web3.0 theme summit to share the evolution of ape community civilization from technology
The difference between MVVM and MVC
Tensor attribute statistics
2022 registration examination for safety management personnel of hazardous chemical business units and simulated reexamination examination for safety management personnel of hazardous chemical busines
All expansion and collapse of a-tree
Expectation, variance and covariance
a-tree 树的全部展开和收起
Business introduction of Zhengda international futures company
随机推荐
Why does the C# compiler allow an explicit cast between IEnumerable< T> and TAlmostAnything?
d3dx9_ What if 29.dll is missing? System missing d3dx9_ Solution of 29.dll file
Ieventsystemhandler event interface
链表之双指针(快慢指针,先后指针,首尾指针)
openresty ngx_lua请求响应
[untitled]
Error when LabVIEW opens Ni instance finder
Roman numeral to integer
2022 Software Test Engineer salary increase strategy, how to reach 30K in three years
[untitled]
第一讲:蛇形矩阵
Simple and beautiful method of PPT color matching
Postman core function analysis - parameterization and test report
VOT Toolkit环境配置与使用
3 find the greatest common divisor and the least common multiple
抖音__ac_signature
Unity Max and min constraint adjustment
PLC编程基础之数据类型、变量声明、全局变量和I/O映射(CODESYS篇 )
[secretly kill little buddy pytorch20 days] - [Day2] - [example of picture data modeling process]
一文搞定class的微觀結構和指令