Very nice, and very obvious (kicks myself that I didn’t think of that). I was getting hung up on the fact that with Tomcat and Jetty you need to them them the proxying info as a separate thing than the app. That might be entirely an implementation detail.
Probably about time I started experimenting with this stuff now. Thanks Shantanu. > On 7 Jul 2015, at 18:08, Shantanu Kumar <[email protected]> wrote: > > 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 > <http://my-server:3000/server1>. /server1 being proxied to > http://my-server:3000/ <http://my-server:3000/> doesn’t work. > > > >> On 7 Jul 2015, at 15:23, Jo Geraerts <j...@ <>umask.net <http://umask.net/>> >> 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 clo...@ <>googlegroups.com >> <http://googlegroups.com/> >> Note that posts from new members are moderated - please be patient with your >> first post. >> To unsubscribe from this group, send email to >> clojure+u...@ <>googlegroups.com <http://googlegroups.com/> >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> <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 clojure+u...@ <>googlegroups.com <http://googlegroups.com/>. >> For more options, visit https://groups.google.com/d/optout >> <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 > <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] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <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.
