I searched this group for:
reverse proxy route/resources
but I found not discussions on this topic, which I find surprising.
I was developing an app and testing it on my local machine. I established my routes like this:
(defroutes app-routes
(GET "/" request (login-form request))
(POST "/" request (login request))
(OPTIONS "/" request (preflight request))
(GET "/signup" request (signup-form request))
(PUT "/signup" request (signup request))
(OPTIONS "/signup" request (preflight request))
(GET "/examples" [] (examples))
(route/resources "/")
(route/not-found "Page not found. Please go to /examples to see how you should use this software."))
(def app
(-> app-routes
(wrap-cookies)
(wrap-keyword-params)
(wrap-multipart-params)
(wrap-nested-params)
(wrap-params)
(wrap-json-params)
(wrap-content-type)
(wrap-not-modified)))
I had a folder layout such that:
/resources
/templates
/public
/img
/js
/css
The templates had links in them such as:
<link rel="stylesheet" href="/css/bootstrap.css" />
<link rel="stylesheet" href="/css/admin.css" />
Everything worked. I then moved this to the real server where this software will live. That server is running Apache. I established a reverse proxy like this:
and then none of my links to CSS or JS worked. I had to change the URLs like this:
<link rel="stylesheet" href="/login/css/bootstrap.css" />
<link rel="stylesheet" href="/login/css/admin.css" />
Maybe that should have been obvious to me. But I wonder if there is a way to set up a reverse proxy such that I would not have to change the URLs in my templates? Is there a way to insulate my Clojure app from whatever URLs Apache is seeing?