Forum Discussion

CSA's avatar
CSA
Icon for Nimbostratus rankNimbostratus
Jan 17, 2011

Simple reverse proxy

Hi,

 

 

I'm trying to do something quite easy but I can't make it work.

 

 

I have an irule like this:

 

 

[...]

 

elseif {[HTTP::path] starts_with "/admin"} { HTTP::redirect pool preprod_admin_pool }

 

[...]

 

 

My pool has two web servers listening on port 8082, and their document root is "/".

 

 

I would like to have "/admin" removed from HTTP:uri on the backend requests (ie client still use myhost.com/admin/)

 

 

 

Can I do this easily ? I had a look to reverseproxy big irule but it looks complicated for what I want to achieve.

 

 

Thanks,

 

  • So, is the issue that the user gets sent to the admin pool by requesting "/admin" which contains /directory/index.html. If the user clicks a link off of index.html, i.e. "/directory/foobar.html," they're no longer being sent to the admin pool, but to the business application. Is that the issue?
  • CSA's avatar
    CSA
    Icon for Nimbostratus rankNimbostratus
    Exactly. That's why I need the /admin on the client side, and no /admin on the server side.

     

  • That makes more sense.

     

     

    I suppose you could do something like this:

     

     

    1. From HTTP_REQUEST, set a variable like "admin" to a value like "1" if [HTTP::path] started with "/admin." We'd then also get rid of "/admin" before sending the request to the server.

     

    2. From HTTP_RESPONSE, we could check if "admin" equaled "1" and if it did, insert a cookie on the user's machine.

     

    3. Then, we'd also add logic to our HTTP_REQUEST event so if the user had such a cookie, we'd send them to the admin pool regardless of whether their request contained /admin.

     

     

    The immediate issue with that would be if the user no longer wanted to go to the admin pool but still had the cookie. I'll give it some thought and see if I can come up with something.
  • Quick question for you. Any chance you could use a different host header for admin traffic?

     

     

    So, "admin.mydomain.com" goes to admin pool while "myapp.mydomain.com" goes to normal pool?

     

     

    That way, you can send the traffic to the proper pool based on the host header rather than worrying about rewriting the path.

     

     

    Just a thought.
  • CSA's avatar
    CSA
    Icon for Nimbostratus rankNimbostratus
    Unfortunately, we can't do this. We already have many URLs and we are migrating from a system working with a /admin in the URL. In the previous configuration, there was a HTTP::redirect, so users saw the admin server hostname in the URL. In the new configuration, I'd like to have this name "masqueraded"