当前位置:网站首页>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 .
边栏推荐
- Post-90s tester: "after joining Ali, this time, I decided not to change jobs."
- 从 1.5 开始搭建一个微服务框架——日志追踪 traceId
- SPSS analysis of employment problems of college graduates
- Element operation and element waiting in Web Automation
- EasyCVR集群部署如何解决项目中的海量视频接入与大并发需求?
- Thinkphp5.1 cross domain problem solving
- Alibaba Tianchi SQL training camp task4 learning notes
- Binary tree (III) -- heap sort optimization, top k problem
- The code generator has deoptimised the styling of xx/typescript.js as it exceeds the max of 500kb
- [speech processing] speech signal denoising and denoising based on MATLAB low-pass filter [including Matlab source code 1709]
猜你喜欢
[screen recording] how to record in the OBS area
一文搞定JVM常见工具和优化策略
透彻理解JVM类加载子系统
[secretly kill little buddy pytorch20 days] - [Day2] - [example of picture data modeling process]
Postman core function analysis - parameterization and test report
一文搞定class的微觀結構和指令
Registration of Electrical Engineering (elementary) examination in 2022 and the latest analysis of Electrical Engineering (elementary)
Commonly used probability distributions: Bernoulli distribution, binomial distribution, polynomial distribution, Gaussian distribution, exponential distribution, Laplace distribution and Dirac delta d
[digital signal denoising] improved wavelet modulus maxima digital signal denoising based on MATLAB [including Matlab source code 1710]
我对新中台模型的一些经验思考总结
随机推荐
Thinkphp5.1 cross domain problem solving
第十七周作业
audiopolicy
Un article traite de la microstructure et des instructions de la classe
Global and Chinese markets for children's amusement facilities 2022-2028: Research Report on technology, participants, trends, market size and share
fibonacci search
使用rewrite规则实现将所有到a域名的访问rewrite到b域名
Nacos installation and service registration
Vision Transformer (ViT)
Expectation, variance and covariance
Request preview display of binary data and Base64 format data
Selenium+Pytest自动化测试框架实战
Error when LabVIEW opens Ni instance finder
Metasploit (MSF) uses MS17_ 010 (eternal blue) encoding:: undefined conversionerror problem
openresty ngx_ Lua regular expression
媒体查询:引入资源
关于MySQL的30条优化技巧,超实用
Nanjing: full use of electronic contracts for commercial housing sales
Registration of Electrical Engineering (elementary) examination in 2022 and the latest analysis of Electrical Engineering (elementary)
如何快速理解复杂业务,系统思考问题?