0

I have an application with name test.war.

Because of Apache installed on my server I have to use another port number for Tomcat applications so after deployment this application available at domain.com:8080/test/.

I decided to create a subdomain in order to remove that ugly 8080 from url, so I setted up the server like described here. So now test.domain.com reffers to domain.com:8080/test/.

Everything seems fine except of one problem - because my application is not ROOT.war and I am using spring:url function every url in the application is translated to /test/bla-bla. So I removed that function. But still have a problem with spring security because it still translates an urls relative to app name i.e. /test/bla-bla.

How can I solve that problem?

Thank you

UPD: I don't want to deploy it as a ROOT application because I have two or three such applications and I wanted to create a subdomain for each one of them

Community
  • 1
  • 1
nKognito
  • 6,297
  • 17
  • 77
  • 138

1 Answers1

1

Spring Security doesn't "translate" URLs. In fact this isn't specific to Spring Security. You'll run into similar issues with any application which does redirects. If you want to hide the context paths of applications which are behind a proxy, then you need to rewrite the URLs at the proxy.

I'd recommend you read the Tomcat Generic Proxy Howto and the section on URL rewriting in particular, as it specifically addresses this issue.

Shaun the Sheep
  • 22,353
  • 1
  • 72
  • 100
  • Thank you for your reply. I know that I can proxy requests by Tomcat, but what if I have a couple of applications? One of them I can redirect (via proxy) to server's root. The another one will use context path during redirection still. So as I understand the ony solution is to use two instances of Tomcat – nKognito Aug 11 '12 at 03:03
  • No, there shouldn't be any need to use multiple instances of tomcat. Rewrite rules have no connection with tomcat instances and the applications should be unaware they are running behind a proxy. The rewrite rules are part of the apache proxy configuration. – Shaun the Sheep Aug 11 '12 at 19:02
  • Could you maybe specify what exactly do you mean? I used proxy and the problem of subdomain redirection is solved. But still my app adds an app name to any url that I described with spring:url tag – nKognito Dec 01 '12 at 17:24
  • I think the Tomcat howto explains all the issues pretty clearly. If there is a specific issue with Spring Security, it might help if you explain what URLs you are talking about and whether they are redirects, embedded in JSPs or whatever. – Shaun the Sheep Dec 02 '12 at 19:02