Maybe this is already available and I'm just missing it.
I have several services running on my domain and I'm using Nginx to reverse proxy them. For example, instead of having to go to example.com:8080 I would go to example.com/calibre.
Calibre's built in web server lets you do this by passing the --url-prefix=/calibre flag. Perhaps something similar could be done here?
_Side note:_ I'm currently using the docker container to run this. Works fine from localhost and it looks beautiful!
Hi @jgillman, i have calibre-web running w/o issues behind Nginx reverse proxy. But you are right in that it doesn't work if you reverse map it to some subfolder path.
I think i will add support for the X-Script-Name header. Then in Nginx you can pass the path prefix like this:
location /calibre {
proxy_pass http://127.0.0.1:8083;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name /calibre;
}
That would work for me!
btw, to prevent access to the script on the original port, it would be nice to have a listen option where you specify the interface/IP the daemon is listening to. I see something like this already in cps.py but I think the place to put it is the config.ini
I, too, am trying to do this by adding it to my existing Windows-based installation of Apache. My other entries (mostly Python-based) are added to conf in the same format. Based on the port settings I configured for calibre-web, I tried adding the following:
<Location /calbooks>
order allow,deny
allow from all
ProxyPass http://localhost:8000
ProxyPassReverse http://localhost:8000
</Location>
When doing so and visiting https://mydomain/calbooks; only some text appears and links fail due to the fact there is no defined proxy path option. If I could configure the proxy path of "/calbooks" for within Apache or calibre-web and use the below, it should work; but obviously don't have the option or know how to do it.
<Location /calbooks>
order allow,deny
allow from all
ProxyPass http://localhost:8000/calbooks
ProxyPassReverse http://localhost:8000/calbooks
</Location>
Any suggestions for how to resolve this? Thanks!
@BzowK @jgillman Let me know if this works for you.
Nginx example:
server {
location /calibre {
proxy_pass http://127.0.0.1:8083;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name /calibre;
}
}
@janeczku Works like a charm! Thanks for the feature.
Hi,
I am trying to achieve the same thing in regular Apache (not Nginx).
Any advise please??
<Location /books>
ProxyPass http://192.168.0.201:8032
ProxyPassReverse http://192.168.0.201:8032
ProxyAddHeaders Host $http_host;
ProxyAddHeaders X-Forwarded-For $proxy_add_x_forwarded_for;
ProxyAddHeaders X-Scheme $scheme;
ProxyAddHeaders X-Script-Name /books;
</Location>
Thank you.
H.
the example in the readme works for me
It did not for met... I will try again. Thank you!
no luck....
has anyone been able to do this with traefik? --url-prefix would make it easier but i havnt been able to find a way to mimic the nginx config
Hello @bcg62,
I make it work behind Traefik (v1.6.3) by adding the property _passHostHeader = true_ in my frontend configuration.
Ex:
[frontends.calibre]
backend = "calibre"
passHostHeader = true
[frontends.calibre.routes.rule1]
rule = "Host:calibre.mydomain.com"
Most helpful comment
Hi @jgillman, i have calibre-web running w/o issues behind Nginx reverse proxy. But you are right in that it doesn't work if you reverse map it to some subfolder path.
I think i will add support for the
X-Script-Nameheader. Then in Nginx you can pass the path prefix like this: