Package ca.uhn.fhir.rest.server
Class ApacheProxyAddressStrategy
java.lang.Object
ca.uhn.fhir.rest.server.IncomingRequestAddressStrategy
ca.uhn.fhir.rest.server.ApacheProxyAddressStrategy
- All Implemented Interfaces:
IServerAddressStrategy
Works like the normal
IncomingRequestAddressStrategy
unless there's
an x-forwarded-host present, in which case that's used in place of the
server's address.
If the Apache Http Server mod_proxy
isn't configured to supply
x-forwarded-proto
, the factory method that you use to create the
address strategy will determine the default. Note that mod_proxy
doesn't set this by default, but it can be configured via
RequestHeader set X-Forwarded-Proto http
(or https)
List of supported forward headers:
- x-forwarded-host - original host requested by the client throw proxy server
- x-forwarded-proto - original protocol (http, https) requested by the client
- x-forwarded-port - original port request by the client, assume default port if not defined
- x-forwarded-prefix - original server prefix / context path requested by the client
If you want to set the protocol based on something other than the constructor
argument, you should be able to do so by overriding protocol
.
Note that while this strategy was designed to work with Apache Http Server,
and has been tested against it, it should work with any proxy server that
sets x-forwarded-host
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondetermineServerBase
(jakarta.servlet.ServletContext servletContext, jakarta.servlet.http.HttpServletRequest request) Determine the server base for a given requeststatic ApacheProxyAddressStrategy
forHttp()
Static factory for instance usinghttp://
static ApacheProxyAddressStrategy
forHttps()
Static factory for instance usinghttps://
Methods inherited from class ca.uhn.fhir.rest.server.IncomingRequestAddressStrategy
setServletPath
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ca.uhn.fhir.rest.server.IServerAddressStrategy
determineServletContextPath
-
Constructor Details
-
ApacheProxyAddressStrategy
- Parameters:
useHttps
- Is used when thex-forwarded-proto
is not set in the request.
-
-
Method Details
-
determineServerBase
public String determineServerBase(jakarta.servlet.ServletContext servletContext, jakarta.servlet.http.HttpServletRequest request) Description copied from interface:IServerAddressStrategy
Determine the server base for a given request- Specified by:
determineServerBase
in interfaceIServerAddressStrategy
- Overrides:
determineServerBase
in classIncomingRequestAddressStrategy
-
forHttp
Static factory for instance usinghttp://
-
forHttps
Static factory for instance usinghttps://
-