Reputation: 9509
I have a tomcat .war
application that has a number of endpoints. Let's say they are:
http://myapp.com/myapp/endpoint.a
http://myapp.com/myapp/endpoint.b
I want http://myapp.com/myapp/endpoint.a
to be available over port 80
, and http://myapp.com:8080/myapp/endpoint.b
to only be available over port 8080
.
I can't have apache in front of tomcat, and it is unacceptable for /myapp/endpoint.b
to be accessible on the same port as /myapp/endpoint.a
.
Splitting the endpoints into different application contexts is also not possible.
use only port:8080 for *.b
8080
in tomcat, and then forwarding *.a*
from 80
to 8080
in apache. But as I said a requirement is to not use apache.Upvotes: 4
Views: 1719
Reputation: 9509
It is solvable at the application level with a combination of:
PortAuthorisationFilter
configured in web.xml
with a filter-mapping of the endpoints we want to restrict:<url-pattern>*.b</url-pattern>
ServletRequest.getLocalPort()
is equal to :8080
and reject the request otherwise. This method claims to be the port used in the TCP connection so cannot be spoofed.At the tomcat level, we have http
connectors at ports 80
and 8080
, that apply to the entire application.
Upvotes: 3