nginx代理tomcat后,tomcat获取真实(非proxy,非别名)nginx服务端ip端口的解决方案
2017-01-16 13:15
573 查看
nginx代理tomcat后,tomcat获取服务端ip端口的解决方案
1.注意修改nginx配置代理,标红地方
2.jsp获取真实服务器 nginx访问 ip 端口
以上经过实际本地测试,可以正常获取
1.注意修改nginx配置代理,标红地方
1 #user nginx; 2 worker_processes 4; 3 4 error_log logs/error.log; 5 #error_log logs/error.log notice; 6 #error_log logs/error.log info; 7 8 pid logs/nginx.pid; 9 10 11 events { 12 worker_connections 1024; 13 } 14 15 16 http { 17 include mime.types; 18 default_type application/octet-stream; 19 20 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 21 '$status $body_bytes_sent "$http_referer" ' 22 '"$http_user_agent" "$http_x_forwarded_for"'; 23 24 access_log logs/access.log main; 25 26 sendfile on; 27 #tcp_nopush on; 28 29 #keepalive_timeout 0; 30 keepalive_timeout 65; 31 32 gzip on; 33 gzip_disable "MSIE [1-6]."; 34 35 client_header_buffer_size 128k; 36 large_client_header_buffers 4 128k; 37 ############你自己的项目####### 38 upstream dj-tomcatwebapp { 39 # sticky; 40 server 127.0.0.1:8085; 41 } 65 ###### 你自己的项目system####### 66 server { 67 listen 8095; 68 server_name 127.0.0.1; 70 charset utf-8; 71 72 #access_log logs/host.access.log main; 73 74 location / { 75 client_max_body_size 1000m; 76 proxy_pass http://dj-tomcatwebapp; 77 proxy_redirect off; 78 proxy_set_header Host $host:$server_port; 79 proxy_set_header X-Real-IP $remote_addr; 80 proxy_set_header X-Real-PORT $remote_port; 82 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 86 87 88 proxy_next_upstream error timeout invalid_header http_500 http_503 http_404; 89 90 } 91 92118 } 119 162204 }
2.jsp获取真实服务器 nginx访问 ip 端口
<% String scheme = request.getScheme(); String serverName = request.getServerName(); int port = request.getServerPort(); String requestURI = scheme+"://"+serverName+":"+port; %> <c:set var="hyrt" value="<%=requestURI%>" />
以上经过实际本地测试,可以正常获取
相关文章推荐
- nginx代理tomcat后,tomcat获取真实(非proxy,非别名)nginx服务端ip端口的解决方案
- 使用nginx做反向代理,后端tomcat日志获取真实ip解决方案
- Nginx反向代理时tomcat日志获取真实IP
- 多层nginx代理tomcat获取客户端真实ip
- Nginx反向代理Tomcat日志获取真实IP
- nginx后的tomcat获取真实用户ip
- 根据IP(有代理的情况)定位城市以及通过nginx转发的tomcat如何得到用户真实的ip
- nginx+tomcat整合后获取真实IP
- nginx 代理模式下,获取客户端真实IP
- nginx代理 获取不到客户端的真实IP问题
- nginx 反向代理使apache或者tomcat日志中无法获取真实IP 的 X-Forwarded-For 参数的设定
- nginx 代理模式下,获取客户端真实IP
- lighttpd获取nginx代理客户端真实IP
- 多级代理下Nginx获取真实用户IP地址的总结
- nginx后的tomcat获取真实用户ip
- 多级代理下Nginx获取真实用户IP地址的总结
- nginx反向代理httpd获取用户真实ip
- nginx后的tomcat获取真实用户ip
- nginx 代理模式下,获取客户端真实IP
- nginx前端代理tomcat取真实客户端IP