客户反馈,为什么配置https请求,使用request.getScheme()、request.getServerPort(),后台获取访问协议和端口的时候还是获取的http和80。。
其中
CDN使用443端口回源
SLB配置安全证书使用HTTPS公网IP访问
EDAS使用Alitomcat,server.xml配置
< Valve className="org.apache.catalina.valves.RemoteIpValve"
remoteIpHeader="x-forwarded-for"
remoteIpProxiesHeader="x-forwarded-by"
protocolHeader="x-forwarded-proto"/>
通过用户沟通已经需求已经比较清晰。
用户希望在后端ECS处,可以拿到客户端真实请求的来源IP(x-forwarded-for)和协议(X-Forwarded-Proto),但目前情况是在自建服务器的tomcat上使用正常,换成阿里服务器后有问题,获得的仍然是http和80。
如果没有配置,则默认IP地址为
Regular expression (using java.util.regex) that a proxy's IP address must match to be considered an internal proxy. Internal proxies that appear in the remoteIpHeader will be trusted and will not appear in the proxiesHeader value. If not specified the default value of 10\.\d{1,3}\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3}|169\.254\.\d{1,3}\.\d{1,3}|127\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.1[6-9]{1}\.\d{1,3}\.\d{1,3}|172\.2[0-9]{1}\.\d{1,3}\.\d{1,3}|172\.3[0-1]{1}\.\d{1,3}\.\d{1,3} will be used.
详细内容可以访问
http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/valves/RemoteIpValve.html