Forum Discussion

Laurent_53635's avatar
Laurent_53635
Icon for Nimbostratus rankNimbostratus
Mar 08, 2010

webmail Rewriting irule

Hello,

I am sure this question has already been asked many times but i do not manage to find the solution in this forum.

I have a VS on my LTM 9.4.5 in https. I want to implement the following behavior

https://site.test.com/IMsurvey/ => http://site1.test.corp/IMsurvey/

https://site.test.com/webmail/ => https://site2.test.corp/

Currently, my Irule is only able to implement that rewriting irule:

https://external.test.com/IMsurvey/ => http://server1.test.corp/IMsurvey/

https://external.test.com/exchange/ => https://server2.test.corp/exchange/

https://external.test.com/exchweb/ => https://server2.test.corp/exchweb/

...

For information, the server 2 is in fact a pool of 2 OWA 2003 and server 1 is a basic web server.

Here my irule:

  
  when HTTP_REQUEST {  
     if {[HTTP::uri] starts_with "/IMsurvey" } {  
        SSL::disable serverside  
        pool pool-IMsurvey   
     }  
     else {  
        if { [HTTP::uri] starts_with "/webmail" } {  
           log local0. "WEBMAIL BEFORE [HTTP::uri]"  
           HTTP::uri "/"  
           log local0. "WEBMAIL AFTER [HTTP::uri]"  
         }  
        SSL::enable serverside  
        pool pool_OWA  
      }  
  }  
  

Please, could you give me reference to a simple example i can follow to fix this irule ?

Thanks a lot.

Laurent
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi Laurent,

    I'm not sure I understand the requirements exactly. Can you take a look at this example which uses a switch statement to check the requested path (URI minus the query string) and see if it looks like it will work for your scenario? If not, can you clarify what else you want to do?

     
     when HTTP_REQUEST { 
      
         Check the requested URI 
        switch -glob [string tolower [HTTP::path]] { 
           "/imsurvey/*" { 
               Path started with /imsurvey/ so disable SSL and select the IMsurvey pool 
              SSL::disable serverside 
              pool pool-IMsurvey 
      
               Exit this event in this rule 
              return 
           } 
           "/webmail" { 
               Path was exactly /webmail so rewrite the path to / 
              HTTP::path "/" 
           } 
        } 
      
         If we're still in the iRule, enable server SSL and select the pool 
        SSL::enable serverside 
        pool pool_OWA 
     } 
     

    Thanks, Aaron
  • Thanks fro you feedback

     

     

    In fact i do not want to redirect but rewrite URI on server side. End user can only reach the external URI.

     

    Aron, I have already tested the command HTTP::path "/" but then we get a strange behavior : web i enter the /webmail, the uri on user side is change to the internal address instead of the external. Then, as internal is not reachable, i get a 404. May be i must add somethink on the the WHEN HHTP_RESPONSE to add the /webmail ...

     

     

    Thanks

     

     

    Laurent
  • Note that you can set the value of HTTP::uri to whatever you want - it can present some fairly tricky situations but it can be done. You may want to look at the proxypass iRule for this as well, which takes a bunch of the edge cases into consideration and fixes them.

     

    -Matt
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    hi Laurent,

     

     

    Can you clarify why are you wanting to rewrite /webmail to / anyhow? Most installations of OWA I've seen require accessing the app using /webmail.

     

     

    As Matt said, you can rewrite the URI using HTTP::uri or the path using HTTP::path. But I'm not sure what you're requirement is. It might help to use a browser plugin like HttpFox for Firefox or Fiddler for IE to see what the client and web app are exchanging in HTTP headers and payloads.

     

     

    Aaron