nginx代理tomcat后,tomcat获取真实(非proxy,非别名)nginx服务端ip端口的解决方案
nginx代理tomcat后,tomcat获取服务端ip端口的解决方案
1.注意修改nginx配置代理,标红地方
#user nginx;
worker_processes ; error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; pid logs/nginx.pid; events {
worker_connections ;
} http {
include mime.types;
default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout ;
keepalive_timeout ; gzip on;
gzip_disable "MSIE [1-6]."; client_header_buffer_size 128k;
large_client_header_buffers 128k;
############你自己的项目#######
upstream dj-tomcatwebapp {
# sticky;
server 127.0.0.1:;
}
###### 你自己的项目system#######
server {
listen ;
server_name 127.0.0.1; charset utf-8; #access_log logs/host.access.log main; location / {
client_max_body_size 1000m;
proxy_pass http://dj-tomcatwebapp;
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; proxy_next_upstream error timeout invalid_header http_500 http_503 http_404; } }
}
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 代理模式下,获取客户端真实IP
最近做博友推荐,发现个小问题,用$_SERVER['REMOTE_ADDR'];得到的都是服务器的地址192.168.96.52,搜索了一下,发现问题,改为$_SERVER['HTTP_X_REAL_ ...
- nginx 代理https后,应用redirect https变成http --转
原文地址:http://blog.sina.com.cn/s/blog_56d8ea900101hlhv.html 情况说明nginx配置https,tomcat正常http接受nginx转发.ngi ...
- NGINX反向代理,后端服务器获取真实IP
一般使用中间件做一个反向代理后,后端的web服务器是无法获取到真实的IP地址. 但是生产上,这又是不允许的,那么怎么解决? 1.在NGINX反向代理服务器上进行修改 2.修改后端web服务器配置文件 ...
- nginx 代理 https 后,应用变成 http
需求:nginx 代理 https,后面的 tomcat 处理 http 请求,sso 的客户端,重定向时需要带上 target,而这个 target 默认是 tomcat 的 http,现在需要把这 ...
- Eclipse-ee 启动Tomcat后浏览器无法访问Tomat,并且Web项目服务部署
环境: Ubuntu 14.04 + Eclipse-ee + Tomcat7 问题: 在Eclipse中建立Server时选择的Tomcat7,Server的运行时选择的时自己安装的Tomcat目 ...
- 有关于腾讯地图服务端IP定位接口的获取当前城市的处理
接口说明:http://apis.map.qq.com/ws/location/v1/ip 说明里面写了ip可以缺省,然并卵,经过测试的到结果并不能获取到当前城市,理由是腾讯ip库的对应ip精度没有定 ...
- 获取与esp8266连接的客户端的Mac地址 IP 端口 控制停止等问题
两个关键的库 ESP8266WebServer.h WiFiClient.h ESP8266WiFiAP.cpp C:\Users\dongdong\Desktop\Arduino-master\li ...
- js获取服务端IP及端口及协议
alert("location:"+window.location); alert("href: "+window.location.href); alert( ...
- nginx代理后,获取request的ip
应用程序部署上线,一般都会用nginx之类的来进行反向代理,而不是直接访问tomcat之类的容器. 这时候如果用平时的获取ip的代码,就只会获取到nginx所在服务器的ip, 就失去了本身的意义. 今 ...
随机推荐
- Codeforces 691B s-palindrome
水题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #includ ...
- 链接libtorrent库时出现的问题
在QtCreator中使用libtorrent库的时候, 项目配置中 libs项配置如下: LIBS += -liconv -ltorrent-rasterbar -lboost_system -lb ...
- xtraReprot 动态绑定数据 数据列动态
这样做并不是我想出来的,是之前做一个报表模板时搜的,原地址忘了 我要做的报表模板要求是传入一个DataTble,不管datatable的列数多少,计算列宽后显示报表 这是我的报表: 灰色那个XRtab ...
- Chapter 1 First Sight——18
But at least he sent me to an empty desk at the back without introducing me to the class. 但是最后他给我最后面 ...
- hdu_5719_Arrange(脑洞题)
题目连接:hdu_5719_Arrange 题意: 给你1-n这 n个数,设一个排列的第i个数为Ai, Bi为A1到Ai的最小值,Ci为C1到Ci的最大值,问你有多少种排列方式,然后输出取模后的答案 ...
- 对比C#中==与equal方法
C#中equal与==的区别 收藏 对于值类型,如果对象的值相等,则相等运算符 (==) 返回 true,否则返回 false.对于string 以外的引用类型,如果两个对象引用同一个对象,则 == ...
- 利用transform制作幻灯片
html代码 <html><head></head><body><div class='hpic'> <ul style=" ...
- 标准与扩展ACL实验
一标准访问控制列表实验: 实验拓扑: 实验目的:掌握标准与扩展ACL的配置 实验要求:拒绝R1到R3的所有流量 实验步骤: 步骤1 按如上拓扑做好底层配置,并检测相邻设备之间的连通性 步骤2起静态路由 ...
- 款待奶牛(treat)
款待奶牛(treat) 题目描述 FJ有n(1≤n≤2000)个美味的食物,他想卖掉它们来赚钱给奶牛.这些食物放在一些箱子里,它们有些有趣的特性:(1)这些食物被编号为1-n,每一天FJ可以从这排箱子 ...
- app每个页面都有一个相同的浮层控件 实现思路
可以创建一个window,设置其windowLevel为alert;