简体   繁体   English

如果tomcat服务器在反向代理后面运行,如何确定请求方案,contextpath

[英]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.

相关问题 Spring pageContext.request.contextPath 与 Apache 后面的 Tomcat 作为反向代理 - Spring pageContext.request.contextPath with Tomcat behind Apache as reverse proxy 带有嵌入式 Tomcat 的 Spring Boot 应用程序在请求 /contextPath 时不重定向到 https 而不使用尾部斜杠 - Spring Boot application with embedded Tomcat behind reverse proxy not redirecting to https when asking for /contextPath without trailing slash 如何获取apache2反向代理和tomcat服务器背后的客户端主机名? - How to get the clients host name behind apache2 reverse proxy and tomcat server? 在AWS实例中设置反向代理,运行Tomcat服务器 - Setting reverse proxy in aws instance, running tomcat server Jetty反向代理后面的Keycloak服务器 - Keycloak server behind Jetty reverse proxy 在反向代理后面的Java应用程序中确定面向用户的URL - Determine user-facing url in a Java application behind a reverse proxy 如何以编程方式确定运行webapp的哪个(负载平衡)tomcat服务器 - How to programmatically determine which (load balanced) tomcat server the webapp is running on 反向代理背后的Csrfguard - Csrfguard behind a reverse proxy 在 nginx 代理后面运行的 tomcat webapp 中的远程 IP - Remote IP in tomcat webapp running behind nginx proxy 如何在 spring 引导中为嵌入式 tomcat 服务器在 apache2 中配置反向代理? - How to configure reverse proxy in apache2 for embedded tomcat server in spring boot?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM