You can set the serverName parameter to the value you need test1.domain.com 
instead of localhost.
This you should be able to do in the glassfish server (in tomcat do this in 
$TOMCAT_HOME/bin/setenv.sh).

CATALINA_OPTS="$CATALINA_OPTS -Dcas.service.host=test1.domain.com"
export CATALINA_OPTS

If test1 and test2 are serving the same content (apache as load balancer), then 
set serverName to the name of the apache server (and configure apache as a load 
balancer instead of two separate virtual hosts).

Ray

On Thu, 2017-12-07 at 05:04 -0800, snaffy wrote:
How to load different views based on the domains if the client application is 
behind the apache2 proxy. Going to details - CAS client configuration requires 
"serverName" parameter.
"The name of the server this application is hosted on. Service URL will be 
dynamically constructed using this, i.e. https://localhost:8443 (you must 
include the protocol, but port is optional if it's a standard port)."). Based 
on it and the relevant service registers, CAS can decide which template to load.
However, my problem comes down to the question of how to load the right view 
when I am using apache2 and virtual glassfish servers.

<VirtualHost *:433>

    ServerName test1.domain.com

    ProxyPass /WebApp http://test1.domain.com:8081/WebApp
    ProxyPassReverse /WebApp http://test1.domain.com:8081/WebApp
    ProxyPass / http://test1.domain.com:8081/WebApp
    ProxyPassReverse / http://test1.domain.com:8081/WebApp

    ProxyPreserveHost On
    ProxyTimeout 1500
    SetEnv           force-proxy-request-1.0 1
    SetEnv           proxy-nokeepalive       1
    SetEnv proxy-initial-not-pooled 1

    RewriteEngine On
    RewriteCond /var/www/maintenance.html -f
    RewriteCond %{REQUEST_FILENAME} !/maintenance.html
    RewriteRule ^.*$    /var/www/maintenance.html [L]
</VirtualHost>

<VirtualHost *:433>

    ServerName test2.domain.com

    ProxyPass /WebApp http://test2.domain.com:8081/WebApp
    ProxyPassReverse /WebApp http://test2.domain.com:8081/WebApp
    ProxyPass / http://test2.domain.com:8081/WebApp
    ProxyPassReverse / http://test2.domain.com:8081/WebApp

    ProxyPreserveHost On
    ProxyTimeout 1500
    SetEnv           force-proxy-request-1.0 1
    SetEnv           proxy-nokeepalive       1
    SetEnv proxy-initial-not-pooled 1

    RewriteEngine On
    RewriteCond /var/www/maintenance.html -f
    RewriteCond %{REQUEST_FILENAME} !/maintenance.html
    RewriteRule ^.*$    /var/www/maintenance.html [L]
</VirtualHost>

Going to the application through the test1.domain.com, the service parameter 
will look like this
https://sso.server.com/cas/login?service=https%3A%2F%2Ftest1.domain.com%2FWebApp%2F
However, it will look the same with test2.domain.com, therefore, cas will not 
load different views because my client has a clearly defined only one 
${cas.service.host}

<bean id="casAuthenticationFilter" 
class="org.jasig.cas.client.authentication.AuthenticationFilter">
        <property name="casServerLoginUrl" value="${cas.server.host}/login"/>
        <property name="serverName" value="https://${cas.service.host}"/>
</bean>

Thanks in advance for your help, any suggestions are welcome.

--
Ray Bon
Programmer analyst
Development Services, University Systems
2507218831 | CLE 019 | [email protected]

-- 
- 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/1512668324.1769.36.camel%40uvic.ca.

Reply via email to