Apache HTTPD as a reverse-proxy for wdk applications

<VirtualHost _default_:80>

  RewriteEngine On
  ProxyPreserveHost On
 
#############################
###
### SSL offloading for Weblogic
###
  
  # RequestHeader set WL-Proxy-SSL "true" env=HTTPS
  
#############################
###
### SSL offloading for Tomcat
### Add following in context.xml if you are going to use http protocol:
### <Valve className="org.apache.catalina.valves.RemoteIpValve"
###      protocolHeader="x-forwarded-proto" />
###

  RequestHeader set X-Forwarded-Proto "https" env=HTTPS

#############################
###
### Tomcat
###

  <Proxy balancer://webtop>

#############################
###
### AJP, preferred
###

    BalancerMember ajp://192.168.2.56:8209 route=app1

#############################
###
### HTTP
###

    # BalancerMember http://192.168.2.56:8280 route=app1

  </Proxy>

#############################
###
### Weblogic
###

    # WLIOTimeoutSecs 3600
    # HungServerRecoverSecs 3600
    # Idempotent OFF
    # DynamicServerList OFF

  <Location /webtop>

#############################
###
### Reverse proxy settings
###

#############################
###
### Tomcat
###

    ProxyPass balancer://webtop/webtop stickysession=ROUTEID nofailover=Off
    Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED

#############################
###
### Weblogic
###

    # WebLogicCluster 192.168.2.56:7001
    # SetHandler weblogic-handler

#############################
###
### Compression settings. Disable wdk compression in web.xml, i.e.:
### <!--
###     <filter-mapping>
###         <filter-name>CompressionFilter</filter-name>
###         <url-pattern>/*</url-pattern>
###         <dispatcher>REQUEST</dispatcher>
###     </filter-mapping>
### -->
### otherwise remove this section 
### 

    SetOutputFilter DEFLATE

    # Disable compression
    SetEnvIf Request_URI ^/ no-gzip
    # Enable default compression settings
    SetEnvIfNoCase Request_URI \.(jsp|html?|css|js)$ !no-gzip
    SetEnvIf Request_URI ^/webtop/(component|action|virtualjs|wdkportlet)/ !no-gzip
    SetEnvIf Request_URI ^/webtop/wdkportlet$ !no-gzip
    # Don't compress images (or other files that are already compressed)
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|zip|7z|rar|sit?x|mp3|flac|ogg|pdf)$ no-gzip dont-vary
    # Don't compress some webtop stuff
    SetEnvIf Request_URI ^/webtop/wdk/container/comboautocommitex.jsp no-gzip dont-vary
    SetEnvIf Request_URI ^/webtop/wdk/container/comboautocommit.jsp no-gzip dont-vary
    SetEnvIf Request_URI ^/webtop/wdk/container/comboautocommitexSimple.jsp no-gzip dont-vary
    SetEnvIf Request_URI ^/webtop/webcomponent/library/progress/launchprogress.jsp no-gzip dont-vary
    SetEnvIf Request_URI ^/webtop/webcomponent/library/progress/realtimeprogress.jsp no-gzip dont-vary
    SetEnvIf Request_URI ^/webtop/webcomponent/library/progress/realtimeprogressSimple.jsp no-gzip dont-vary
    SetEnvIf Request_URI ^/webtop/webcomponent/library/searchresultslist/search60/searchresults.jsp no-gzip dont-vary
    SetEnvIf Request_URI ^/webtop/component/getcontent no-gzip dont-vary
    SetEnvIf Request_URI ^/webtop/component/searchmonitoring no-gzip dont-vary

    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
  </Location>

###############################
###
### Static content offloading
###

  Alias /static-webtop/ "/var/www/html/webtop/"
  <Directory "/var/www/html/webtop/">
    Options -Indexes
    SetOutputFilter DEFLATE

    # Disable compression
    SetEnvIf Request_URI ^/ no-gzip
    SetEnvIf Request_URI ^/ Deny
    # Enable default compression settings
    SetEnvIfNoCase Request_URI \.(html?|css|js)$ !no-gzip
    SetEnvIfNoCase Request_URI \.(jpe?g|gif|png|css|js|txt|ico|pdf)$ !Deny

    Order allow,deny
    Allow from all
    Deny from env=Deny
  </Directory>

  RewriteCond %{REQUEST_URI}             !^/webtop/drl
  RewriteCond %{REQUEST_URI}             !\?
  RewriteCond %{REQUEST_URI}             !\&
  RewriteCond %{REQUEST_URI}             ^/webtop/(_./.*?-.*?/)?(.*)
  RewriteCond %{REQUEST_FILENAME}        \.(jpe?g|gif|png|css|js|txt|ico|pdf)$ [NC]
  RewriteCond /var/www/html/webtop/%2    -f
  RewriteRule /webtop/(_./.*?-.*?/)?(.*) /static-webtop/$2 [PT,L]

#################################
###
### Default redirects
###

  RewriteCond %{REQUEST_URI}      ^/?$
  RewriteRule .*                  /webtop/ [R,L]

  RewriteCond %{REQUEST_URI}      ^/webtop$
  RewriteRule .*                  /webtop/ [R,L]
</VirtualHost>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s