Closed darylrichards closed 1 year ago
Libki supports Catalyst::TraitFor::Request::ProxyBase ( https://metacpan.org/pod/Catalyst::TraitFor::Request::ProxyBase ) for exactly this scenario. Just set up your proxy URLs however you want them and send an X-Request-Base header with the "real" Libki server URL.
Here is an example for Apache that you could use if Libki Server were running on the same host as Apache:
<Virtualhost *:80>
ProxyRequests Off
<Location /preview>
# You must have mod_headers enabled for that
# RequestHeader set X-Request-Base /preview
RequestHeader set X-Request-Base http://127.0.0.1:3000
</Location>
ProxyPass / http://my.libki.host/
ProxyPassReverse / http://my.libki.host/
</Virtualhost>
Sorry it's been so long... Looping back to this.
It's not running on the same host. But no matter what I set the name to, when it creates the links, it still keeps appending the :3000 port on the end of URLs.
proxy_pass http://10.160.12.64:3000;
add_header X-Request-Base https://libki.x.x;
URL created: http://libki.x.x:3000/public/login
This still sounds like an nginx configuration issue. You might use something like Wireshark to check the header value before it gets to the Libki server.
In addition to working with Apache, I am also using this feature with Traefik. Here's an example Traefik config using lables:
libki-mylibrary:
image: quay.io/libki/libki-server:alpine-r23.07
networks:
- traefik-public
deploy:
mode: replicated
resources:
limits:
memory: 400M
labels:
- "traefik.enable=true"
- "traefik.constraint-label=traefik-public"
- "traefik.http.middlewares.libki-mylibrary-headers.headers.customrequestheaders.libki-instance=mylibrary"
- "traefik.http.middlewares.libki-mylibrary-headers.headers.customrequestheaders.X-Request-Base=https://mylibrary.libki.bywatersolutions.com"
- "traefik.http.routers.libki-mylibrary.rule=Host(`mylibrary.libki.bywatersolutions.com`)"
- "traefik.http.routers.libki-mylibrary.entrypoints=http"
- "traefik.http.services.libki-mylibrary.loadbalancer.server.port=3000"
- "traefik.http.routers.libki-mylibrary.middlewares=libki-mylibrary-headers"
Ends up it is my fault. I should have thought of packet capture myself.
For everyone else: In nginx, you need to use proxy_set_header
, not add_header
Excellent! It's great to know you solved your problem. Thanks for sharing!
Is your feature request related to a problem? Please describe. We have installed libki and it's working for us. But we'd like to run it behind an nginx proxy. This doesn't work as some url's are having the port appending to them.. Not all though.
Describe the solution you'd like Don't add port numbers to generated URLs.
Describe alternatives you've considered I tried adding a the parameters to the Catalyst config to indicate it's behind a proxy. That made things work... So much for a quick patch...
Additional context