Hi,
I’m currently using an Nginx Reverse Proxy for all my services (Jellyfin, Ombi, Radarr…) and I’m looking to add Komga to it.
I’ve already set a subpath to Komga, by adding this line in the application.yml of Komga :
servlet.context-path: /komga/
The subpath looks like it’s working correctly, because when accessing it locally with [localip]:2037, it automatically becomes [localip]:2037/komga/. And everything works locally.
But now I’m trying to add the Nginx configuration as Komga.conf.
location /komga/ {
proxy_http_version 1.1;
auth_request off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://127.0.0.1:2037/komga/;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
location /komga/api {
auth_request off;
proxy_pass http://127.0.0.1:2037/komga/api;
}
location /komga/opds {
auth_request off;
proxy_pass http://127.0.0.1:2037/komga/opds;
}
Here is my full Nginx config : https://pastebin.com/DxnCzQwg
I can’t manage to get this to work. I tried multiple configurations, but I can’t find the solution. When trying to access [mydomain]/komga with this config, I get a HTTP Status 400 – Bad Request error. I asked the Komga discord but it looks like there is very few people using Nginx with Komga. So I’m asking here.
Any help, any answer is welcome.
Have a great day !
I think the last two location blocks are not required as the first does the desires proxy_pass already. Did you try it with the most simple variant:
location /komga/ {
include proxy_params;
proxy_pass http://127.0.0.1:2037/;
}
While writing I recognised that you appended /komga/ as well to the target, while by default Komga is accessible at the root. So either the above may work or you need to configure Komga to listen on the sub path. The include sets the headers, check out /etc/nginx/proxy_params.
Hi,
Thanks for your reply.
I just tried with your setting. Thanks for noticing the proxy_params, I didn’t.
Sadly I still have the same issue : I get a HTTP Status 400 – Bad Request error when trying accessing Komga on the reverse proxy.
I’m still unsure if the problem comes from Komga or Nginx, on Komga discord and github people don’t agree on this. But for me it more looks like it comes from Nginx. You said that Komga has to listen on the subpath. I think it’s the case as I can locally access Komga on http://[localip]/komga. The subpath is correctly set. Maybe there is more to do but I don’t know what. I think Komga requires more settings in the reverse proxy configuration but I can’t find what either.
Ah I missed that you did already set the subpath with Komga and that you can access locally. Yes then it’s fully correct to add it to the proxy target as well, of course, even that Komga seems to do the redirect in case it’s missing.
Do I understand it right that Komga can be accessed locally via proxy (not defining the port 2037) already? Probably it has something to so with the HTTPS termination and that Komga doesn’t deal well with the proxy headers
. Can you share a link to the discussions at Komga GitHub and Discord?
Do I understand it right that Komga can be accessed locally via proxy (not defining the port 2037) already?
—> No, Komga can’t be accessed at all via the proxy, both locally and remotely. What I meant is that I can access it without the proxy locally (or remotely if I open the port 2037). It was to prove that the subpath was correctly set, as it is added when accessing it without the proxy too. So in short :
- http://[localip]:2037/komga works
- http://[localip]:2037 redirects to the above
- https://[mydomain]/komga gives a 400 error
Probably it has something to so with the HTTPS termination and that Komga doesn’t deal well with the proxy headers > ![:thinking: :thinking:](https://dietpi.com/forum/images/emoji/twitter/thinking.png?v=12)
----> I’m a begginer but yeah, it seems it has something to do with incorrect headers
Can you share a link to the discussions at Komga GitHub and Discord?
----> Of course, here is my discussion on github : Can't find the correct Nginx Reverse Proxy configuration for Komga · Issue #690 · gotson/komga · GitHub. The discussions on Discord lead to the same result. I got some example configs for Nginx but all of them were approximately the same thing and lead to a 400 error. Looks like there is very few people using Komga with Nginx. I found one who was using it, I’m waiting his answer to get his full Nginx config and not just the Komga location blocks.
Check out my answer on GitHub: https://github.com/gotson/komga/issues/690#issuecomment-928136182
The proxy works well here with HTTP and HTTPS with nothing more than adding:
servlet.context-path: /komga
to the “server:” section just below the port, and:
location /komga {
proxy_pass http://127.0.0.1:2037/komga;
}
without any fancy headers etc.