본문 바로가기

WEB-SERVER/OHS & JBCS & Apache

[OHS 12.2.1.4] URL redirect

728x90

보통 차세대 전환 작업을 하게 된다면, 도메인 주소는 그대로 가지고 가는게 흔한 일인텐데..

AS-IS와 TO-BE의 도메인 주소가 다르다며, 도메인 redirect가 되는지 확인이 들어왔다.

 

그덕에 테스트 해봤는데, 일단 로컬에서는 되더라.

DNS는 그냥 윈도우 상에 hosts 파일에 적어둔 상태로 테스트를 진행했다.

그리고 별도 장비에서도 테스트는 해보겠지만, 우선 동일 장비에 virtualhost를 구성해서 테스트 해봤다.

 

mod_wl_ohs.conf

LoadModule weblogic_module   "${PRODUCT_HOME}/modules/mod_wl_ohs.so"

## This empty block is needed to save mod_wl related configuration from EM to this file when changes are made at the Base Virtual Host Level
#<IfModule weblogic_module>
##      WebLogicHost <WEBLOGIC_HOST>
##      WebLogicPort <WEBLOGIC_PORT>
##      MatchExpression *.jsp
#       #WebLogicCluster xxx.xxx.xx.xxx:7002,xxx.xxx.xx.xxx:7002
##       WebLogicCluster xxx.xxx.xx.xxx:7002
#       #MatchExpression *.jsp
##       MatchExpression *
##       WLCookieName JSESSIONID
#</IfModule>
#<Location />
#      WebLogicCluster 1xxx.xxx.xx.xxx:7002
#      SetHandler weblogic-handler
#</Location>
##<Location /app>
##      WebLogicCluster xxx.xxx.xx.xxx:7002
##      SetHandler weblogic-handler
##</Location>
#
#
#
## <Location /weblogic>
##      SetHandler weblogic-handler
##      PathTrim /weblogic
##      ErrorPage  http:/WEBLOGIC_HOME:WEBLOGIC_PORT/
##  </Location>
#
#
<VirtualHost xxx.xxx.xx.xxx:80>
    ServerName asis.co.kr
    ErrorLog "||${PRODUCT_HOME}/bin/rotatelogs /logs/asis/error_log-%Y%m%d 86400 604800"
    CustomLog "||${PRODUCT_HOME}/bin/rotatelogs /logs/asis/access_log-%Y%m%d 86400 604800" combined

        <IfModule weblogic_module>
                WebLogicCluster xxx.xxx.xx.xxx:8002
                MatchExpression *
                Idempotent OFF
                WLIOTimeoutSecs 600
        </IfModule>
        <Location />
                WebLogicCluster xxx.xxx.xx.xxx:8002
                SetHandler weblogic-handler
        </Location>
	## http to https ##
	RewriteEngine On
	RewriteCond %{HTTPS} !on
	RewriteCond %{HTTP_HOST} "asis.co.kr"
	RewriteRule ^/(.*)$ https://tobe.co.kr:443/app/ [R,L]
</VirtualHost>

<VirtualHost xxx.xxx.xx.xxx:80>
    ServerName tobe.co.kr
    ErrorLog "||${PRODUCT_HOME}/bin/rotatelogs /logs/tobe/error_log-%Y%m%d 86400 604800"
    CustomLog "||${PRODUCT_HOME}/bin/rotatelogs /logs/tobe/access_log-%Y%m%d 86400 604800" combined

        <IfModule weblogic_module>
                WebLogicCluster xxx.xxx.xx.xxx:7002
                MatchExpression *
                Idempotent OFF
                WLIOTimeoutSecs 600
        </IfModule>
        <Location />
                WebLogicCluster xxx.xxx.xx.xxx:7002
                SetHandler weblogic-handler
        </Location>
        ## http to https ##
        RewriteEngine On
        RewriteCond %{HTTPS} !on
        RewriteCond %{HTTP_HOST} ^tobe.co.kr$
	RewriteCond %{REQUEST_URI} ^/$ [NC]
        RewriteRule ^/(.*)$ https://tobe.co.kr:443/app/ [R,L]
</VirtualHost>

 

ssl.conf

###################################################################
# Oracle HTTP Server mod_ossl configuration file: ssl.conf        #
###################################################################

# The Listen directive below has a comment preceding it that is used
# by tooling which updates the configuration.  Do not delete the comment.
#[Listen] OHS_SSL_PORT
Listen 443

<IfModule ossl_module>


##
## SSL Virtual Host Context
##
#[VirtualHost] OHS_SSL_VH
<VirtualHost *:443> 
    ServerName asis.co.kr
    ErrorLog "||${PRODUCT_HOME}/bin/rotatelogs /logs/asis/error_log-%Y%m%d 86400 604800"
    CustomLog "||${PRODUCT_HOME}/bin/rotatelogs /logs/asis/access_log-%Y%m%d 86400 604800" combined
  <IfModule ossl_module>
   
   ...

  </IfModule>
  <IfModule weblogic_module>
            WebLogicCluster 192.168.56.101:8002
            MatchExpression *
            Idempotent OFF
            WLIOTimeoutSecs 600
  </IfModule>
  <Location />
           WebLogicCluster 192.168.56.101:8002
           SetHandler weblogic-handler
   </Location>
        ## http to https ##
	RewriteEngine On
        RewriteCond %{HTTPS} on
        RewriteCond %{HTTP_HOST} "asis.co.kr"
        RewriteRule ^/(.*)$ https://tobe.co.kr:443/app/ [R,L]
</VirtualHost>
<VirtualHost *:443> 
    ServerName tobe.co.kr
    ErrorLog "||${PRODUCT_HOME}/bin/rotatelogs /logs/tobe/error_log-%Y%m%d 86400 604800"
    CustomLog "||${PRODUCT_HOME}/bin/rotatelogs /logs/tobe/access_log-%Y%m%d 86400 604800" combined
  <IfModule ossl_module>
   
   ...

  </IfModule>
  <IfModule weblogic_module>
         WebLogicCluster 192.168.56.101:7002
         MatchExpression *
         Idempotent OFF
         WLIOTimeoutSecs 600
  </IfModule>
  <Location />
         WebLogicCluster 192.168.56.101:7002
         SetHandler weblogic-handler
  </Location>

        ## http to https ##
	     RewriteEngine On
        RewriteCond %{HTTP_HOST} ^tobe.co.kr$
        RewriteCond %{REQUEST_URI} ^/$ [NC]
        RewriteRule ^/(.*)$ https://tobe.co.kr:443/app/ [R,L]



</VirtualHost>

</IfModule>

 

설명

1)  asis.co.kr 접근하면, https://tobe.co.kr/app으로 리다이렉트 

 

2) tobe.co.kr 접근하며, uri가 / 인 경우, https://tobe.co.kr/app으로 리다이렉트