This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-10
Channels
- # aleph (1)
- # beginners (4)
- # biff (7)
- # calva (7)
- # cider (8)
- # clara (17)
- # clerk (19)
- # clj-kondo (30)
- # clojure (12)
- # clojure-austin (1)
- # clojure-europe (12)
- # clojure-losangeles (1)
- # clojure-norway (21)
- # clojurescript (2)
- # datalevin (1)
- # datomic (24)
- # duct (3)
- # fulcro (8)
- # hyperfiddle (8)
- # lambdaisland (4)
- # membrane (6)
- # missionary (7)
- # off-topic (55)
- # overtone (2)
- # reagent (4)
- # reitit (4)
- # releases (6)
- # shadow-cljs (80)
hello, I'm building compojure api service and it is behind reverse http proxy (with url rewrite rule /external-name/ -> /). It works fine except swagger ui (it expects everything on / instead of /external-name/). Is there a way to tell comporuje/compojure-api/swagger or ring/jetty that it is behind reserve http proxy and base path is /external-name/ instead of "/")? Or am I expecting some non-existing magic instead of simply creating my routing rules with /external-name/? 🙂
Answer to your question: Yes. Hyperlinks are wrong. well, I wasn't probably very clear. I'm using lighttpd with url-rewrite rule, so http://external.example.com/external-name/api/service is forward to http://localhost:3000/api/service (and the /external-name/ is stripped from URL in forward request). remark: My "service" is very simple, the response is some string without any URL/URI so it isn't relevant if external URL (/external-name/api/service) is different to internal (/api/service). but that isn't case for swagger which generates URL and it assumes is /api/service. As a workaround I set routing rules in comporuje-api including external-name and removed lighttpd url-write rule. Now everything works (there is no any difference between external and internal URL, except hostname), but I'm not sure if this is state-of-art approach for comporuje-api behind reserve http proxy.
In general, it's most flexible to produce relative hyperlinks. Swagger probably has a setting for the context root. But in any case, Compojure just generates a Ring handler, so you could wrap it with another Ring handler that "restored" /external-name to the request map before relaying the request to Compojure.