[英]How to determine request scheme, contextpath if tomcat server is running behind reverse proxy
I am building a plugin for a web application in java which is running on Tomcat and behind a apache reverse proxy server. 我正在用Tomcat和Apache反向代理服务器后面的Java构建Web应用程序的插件。
I am able to get the following: 我可以得到以下信息:
Host Name : request.getLocalName()
Port: request.getLocalPort()
How can I get the following for original request, not for proxy request: 我如何获得以下原始请求,而不是代理请求:
Request Scheme : ?? 请求方案:
Context Path: ?? 上下文路径:??
To get the authentication scheme used to protect the Servlet you can call from class HttpServletRequest
the method getAuthType()
. 要获取用于保护Servlet的身份验证方案,可以从类HttpServletRequest
调用方法getAuthType()
。 This will return values matching the static finals as specified in the javadocs. 这将返回与javadocs中指定的静态finals匹配的值。
Field Summary:
static String BASIC_AUTH
String identifier for Basic authentication.
static String CLIENT_CERT_AUTH
String identifier for Client Certificate authentication.
static String DIGEST_AUTH
String identifier for Digest authentication.
static String FORM_AUTH
String identifier for Form authentication.
To get the context path you would just call getContextPath()
of HttpServletRequest. 要获取上下文路径,您只需调用HttpServletRequest的getContextPath()
。
EDIT: 编辑:
To get the local machine name of the server behind the proxy you could get the localhost machine name: 要获取代理后面的服务器的本地计算机名称,您可以获取本地主机名称:
java.net.InetAddress localMachine = java.net.InetAddress.getLocalHost();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.