I think what you need on the http-kit side is a context "stripper" 
middleware, because http-kit would receive a URI like /server1/foo/bar that 
needs to be stripped down to /foo/bar to match your app routes.

(defn strip-middleware
  [handler ^String prefix]
  (let [plen (count prefix)]
    (fn [request]
      (let [^String uri (:uri request)]
        (if (.startsWith uri prefix)
          (handler (assoc request :uri (subs uri plen)))
          (handler request))))))

Call it like: (strip-middleware handler "/server1")

I didn't test this, but should be close to what might cut it.

Shantanu

On Tuesday, 7 July 2015 20:56:25 UTC+5:30, Colin Yates wrote:
>
> Thanks Jo. The problem I have is that I have a bunch of hosts behind a 
> single Apache server which ProxyForwards over SSL. My Apache FU isn’t great 
> and I have only managed to get this to work if there is symmetry between 
> the URL coming in and the context root on the machine being proxied, i.e. 
> /server1 is proxied to something like http://my-server:3000/server1. 
> /server1 being proxied to http://my-server:3000/ doesn’t work.
>
>
>
> On 7 Jul 2015, at 15:23, Jo Geraerts <[email protected] <javascript:>> wrote:
>
> I think you don't. 
>
> But you can make a small piece of middleware that dispatches to a 
> different handler based on the 'context root'. You can also strip off the 
> context root as u dispatch the request to the correct handler. 
>
> I'm doing something similar with virtual hosts. 
>
> (ns net.umask.imageresizer.vhost)
>
> (defn vhost-handler [vhosts]
>   (fn [request]
>     (let [hostname (:server-name request)
>           handler (get-in vhosts [hostname :handler])]
>       (if-not (nil? handler)
>         (handler request)
>         {:status 404
>          :body "vhost config not found"}))))
>
>
> Hope you can work with this. 
>
>
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected] <javascript:>
> Note that posts from new members are moderated - please be patient with 
> your first post.
> To unsubscribe from this group, send email to
> [email protected] <javascript:>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to