Forwarding from root context with embedded tomcat

725 views
Skip to first unread message

Joshua Swink

unread,
Jun 21, 2018, 5:11:04 PM6/21/18
to CAS Community
I'm using CAS 5.2.5 with the embedded Tomcat app server, and I would like to have the root context redirect to /cas/. If I were using Tomcat separately, I would place this JSP file in $CATALINA_HOME/webapps/ROOT, but that solution doesn't seem to apply here. Is there some way to build or configure the WAR file to do this?

<html>
<head>
<title>Welcome to CAS</title>
</head>
<body>
    <p>Redirecting to SSO</p>
    <%
        response.setStatus(301);
        response.setHeader("Location", "/cas/login");
    %>
</body>
</html>

Chia-Ying (David) Yang

unread,
Jun 22, 2018, 10:27:17 AM6/22/18
to cas-...@apereo.org
Since CAS is ultimately a Spring Boot application, you can probably setup additional dispatcher servlets to field requests targeting paths outside the default context path "/cas".  But I don't think it's worth pursuing because of the amount of customization to the default war-overlay-template setup will make your CAS hard to maintain in the future.  You are much better off not using the embedded Tomcat, but deploy CAS to Tomcat and continue using your jsp file solution.  Alternatively have a fronting web server do the redirect for you.

David
--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/c9b57481-e92c-4151-b966-0d0171ad664f%40apereo.org.

Dmitriy Kopylenko

unread,
Jun 22, 2018, 10:59:15 AM6/22/18
to cas-...@apereo.org
You could override Boot’s `server.context-path` property like so:

java -jar /path/to/your/cas.war --server.context-path=/

Cheers,
D.

Dmitriy Kopylenko

unread,
Jun 22, 2018, 11:00:58 AM6/22/18
to cas-...@apereo.org
Oh, I see.. you want the root context to do the redirect to /cas… Never mind then ;-)

D.

Chia-Ying (David) Yang

unread,
Jun 22, 2018, 11:00:59 AM6/22/18
to cas-...@apereo.org
But wouldn't that change all the CAS endpoints from /cas/xyz to /xyz?

David

Dmitriy Kopylenko

unread,
Jun 22, 2018, 11:01:36 AM6/22/18
to cas-...@apereo.org
Yep, it would. As I noted in my other email - never mind ;-)
Reply all
Reply to author
Forward
0 new messages