gotson / komga

Media server for comics/mangas/BDs/magazines/eBooks with API, OPDS and Kobo Sync support
https://komga.org
MIT License
3.9k stars 232 forks source link

Komga fails to load with context-path set #1110

Closed Berserkir-Wolf closed 1 year ago

Berserkir-Wolf commented 1 year ago

Steps to reproduce

Using either option 1 or 2, ensuring the other option is removed to prevent conflict.

Option 1:

  1. Add the following to application.yml
    server:
    servlet:
    context-path: /komga
  2. Start komga container
  3. Attempt to open web UI.

Option 2:

  1. Add the following environment variable:
    SERVER_SERVLET_CONTEXT_PATH = /komga
  2. Start komga container
  3. Attempt to open web UI.

Expected behavior

I should be able to open the Komga UI on http://IP.of.komga.host:10085/komga or via my reverse proxy on https://media.server.site/komga.

Actual behavior

No UI loads if I connect directly.

Reverse proxy shows error 502 if I attempt to connect via that (cannot access proxied content, caused by the above issue).

Logs

2023-04-17 11:42:41.702  INFO 1 --- [main] org.gotson.komga.ApplicationKt           : Starting ApplicationKt using Java 11.0.18 on komga-64ddfb54d9-tf426 with PID 1 (/app/BOOT-INF/classes started by ? in /app)
2023-04-17 11:42:41.705  INFO 1 --- [main] org.gotson.komga.ApplicationKt           : No active profile set, falling back to 1 default profile: "default"
2023-04-17 11:42:46.545  INFO 1 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-04-17 11:42:46.559  INFO 1 --- [main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-04-17 11:42:46.560  INFO 1 --- [main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.68]
2023-04-17 11:42:46.678  INFO 1 --- [main] o.a.c.c.C.[Tomcat].[localhost].[/komga]  : Initializing Spring embedded WebApplicationContext
2023-04-17 11:42:46.678  INFO 1 --- [main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4905 ms
2023-04-17 11:42:47.130  INFO 1 --- [main] com.zaxxer.hikari.HikariDataSource       : SqliteUdfPool - Starting...
2023-04-17 11:42:47.365  INFO 1 --- [main] com.zaxxer.hikari.HikariDataSource       : SqliteUdfPool - Start completed.
2023-04-17 11:42:47.864  INFO 1 --- [main] o.s.b.a.e.web.ServletEndpointRegistrar   : Registered '/actuator/jolokia' to jolokia-actuator-endpoint
2023-04-17 11:42:47.890  INFO 1 --- [main] io.hawt.HawtioContextListener            : Initialising hawtio services
2023-04-17 11:42:47.946  INFO 1 --- [main] io.hawt.system.ConfigManager             : Configuration will be discovered via system properties
2023-04-17 11:42:47.948  INFO 1 --- [main] io.hawt.jmx.JmxTreeWatcher               : Welcome to Hawtio 2.16.1
2023-04-17 11:42:47.959  INFO 1 --- [main] i.h.w.auth.AuthenticationConfiguration   : Starting hawtio authentication filter, JAAS realm: "karaf" authorized role(s): "admin,manager,viewer" role principal classes: ""
2023-04-17 11:42:47.961  INFO 1 --- [main] io.hawt.web.auth.LoginRedirectFilter     : Hawtio loginRedirectFilter is using 1800 sec. HttpSession timeout
2023-04-17 11:42:48.163  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,journalDirectory=/config/artemis/journal,bindingsDirectory=/config/artemis/bindings,largeMessagesDirectory=/config/artemis/largemessages,pagingDirectory=/config/artemis/paging)
2023-04-17 11:42:48.207  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221013: Using NIO Journal
2023-04-17 11:42:48.315  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221057: Global Max Size is being adjusted to 1/2 of the JVM max size (-Xmx). being defined as 805,306,368
2023-04-17 11:42:48.338  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221043: Protocol module found: [artemis-server]. Adding protocol support for: CORE
2023-04-17 11:42:48.406  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221034: Waiting indefinitely to obtain live lock
2023-04-17 11:42:48.407  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221035: Live Server Obtained live lock
2023-04-17 11:42:48.777  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221080: Deploying address DLQ supporting [ANYCAST]
2023-04-17 11:42:48.780  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221003: Deploying ANYCAST queue DLQ on address DLQ
2023-04-17 11:42:48.799  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221080: Deploying address ExpiryQueue supporting [ANYCAST]
2023-04-17 11:42:48.802  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221003: Deploying ANYCAST queue ExpiryQueue on address ExpiryQueue
2023-04-17 11:42:48.803  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221003: Deploying ANYCAST queue tasks.background on address tasks.background
2023-04-17 11:42:48.805  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221003: Deploying MULTICAST queue domain.events on address domain.events
2023-04-17 11:42:48.909  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221007: Server is now live
2023-04-17 11:42:48.909  INFO 1 --- [main] org.apache.activemq.artemis.core.server  : AMQ221001: Apache ActiveMQ Artemis Message Broker version 2.19.1 [localhost, nodeID=7807eb8d-dca6-11ed-b347-faed50b6d13e] 
2023-04-17 11:42:49.147  INFO 1 --- [main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 8.5.13 by Redgate
2023-04-17 11:42:49.148  INFO 1 --- [main] o.f.c.internal.license.VersionPrinter    : See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.13
2023-04-17 11:42:49.148  INFO 1 --- [main] o.f.c.internal.license.VersionPrinter    : 
2023-04-17 11:42:49.165  INFO 1 --- [main] o.f.c.i.database.base.BaseDatabaseType   : Database: jdbc:sqlite:/config/database.sqlite (SQLite 3.40)
2023-04-17 11:42:49.234  INFO 1 --- [main] o.f.core.internal.command.DbValidate     : Successfully validated 57 migrations (execution time 00:00.045s)
2023-04-17 11:42:49.239  INFO 1 --- [main] o.f.core.internal.command.DbMigrate      : Current version of schema "main": 20230116112647
2023-04-17 11:42:49.240  INFO 1 --- [main] o.f.core.internal.command.DbMigrate      : Schema "main" is up to date. No migration necessary.
2023-04-17 11:42:51.586  INFO 1 --- [main] c.g.g.n.j.i.plugins.JxlImageReaderSpi    : This plugin only supports Java 19, plugin will be disabled
2023-04-17 11:42:51.629  INFO 1 --- [main] o.g.k.i.image.ImageConverter             : Supported read formats: [JPG, JPEG 2000, tiff, bmp, PCX, wbp, bigtiff, gif, WBMP, PNG, RAW, JPEG, PNM, BigTIFF, tif, TIFF, wbmp, jpeg, jbig2, jpeg-lossless, jpg, JPEG2000, BMP, pcx, WBP, GIF, png, raw, BIGTIFF, JPEG-LOSSLESS, webp, JBIG2, pnm, TIF, WEBP, jpeg2000, jpeg 2000]
2023-04-17 11:42:51.630  INFO 1 --- [main] o.g.k.i.image.ImageConverter             : Supported read mediaTypes: [image/vnd.wap.wbmp, image/jpeg, image/x-portable-graymap, image/bmp, image/gif, image/x-windows-pcx, image/x-pc-paintbrush, image/x-raw, image/webp, image/x-pcx, image/x-portable-bitmap, image/x-jb2, image/png, image/pcx, image/x-windows-bmp, image/x-webp, image/jpeg2000, image/jp2, image/x-bmp, image/x-png, image/x-portable-pixmap, image/tiff, image/x-jbig2, image/x-tiff, image/x-portable-anymap]
2023-04-17 11:42:51.631  INFO 1 --- [main] o.g.k.i.image.ImageConverter             : Supported write formats: [JPG, JPEG 2000, tiff, bigtiff, bmp, PCX, gif, WBMP, PNG, RAW, JPEG, PNM, BigTIFF, tif, TIFF, wbmp, jpeg, jpg, JPEG2000, BMP, pcx, GIF, png, BIGTIFF, raw, pnm, TIF, jpeg2000, jpeg 2000]
2023-04-17 11:42:51.631  INFO 1 --- [main] o.g.k.i.image.ImageConverter             : Supported write mediaTypes: [image/vnd.wap.wbmp, image/png, image/jpeg, image/x-portable-graymap, image/bmp, image/pcx, image/gif, image/x-windows-bmp, image/x-windows-pcx, image/jpeg2000, image/x-pc-paintbrush, image/x-raw, image/x-bmp, image/jp2, image/x-pcx, image/x-png, image/x-portable-bitmap, image/x-portable-pixmap, image/tiff, image/x-tiff, image/x-portable-anymap]
2023-04-17 11:42:52.870  INFO 1 --- [main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [public/index.html]
2023-04-17 11:42:54.658  INFO 1 --- [main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 20 endpoint(s) beneath base path '/actuator'
2023-04-17 11:42:54.693  INFO 1 --- [main] o.g.k.i.security.SecurityConfiguration   : RememberMe is active, validity: PT720H
2023-04-17 11:42:54.765  INFO 1 --- [main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@2fb9695a, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@33da0fad, org.springframework.security.web.context.SecurityContextPersistenceFilter@5f67ff3e, org.springframework.security.web.header.HeaderWriterFilter@68bef3df, org.springframework.web.filter.CorsFilter@712eb075, org.springframework.security.web.authentication.logout.LogoutFilter@617d697, org.springframework.security.web.session.ConcurrentSessionFilter@60052518, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@2357f000, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@4ac1544f, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@4578d654, org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter@6bea0866, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@1cd4082a, org.springframework.security.web.session.SessionManagementFilter@38f2342b, org.springframework.security.web.access.ExceptionTranslationFilter@638b05fb, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@11ce61d1]
2023-04-17 11:42:55.514  INFO 1 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path '/komga'
2023-04-17 11:42:55.993  INFO 1 --- [main] org.gotson.komga.ApplicationKt           : Started ApplicationKt in 15.084 seconds (JVM running for 16.071)
2023-04-17 11:42:55.983  INFO 1 --- [scheduling-1] .AuthenticationActivityCleanupController : Remove authentication activity older than 2023-03-16T23:42:55.979736 (UTC)
2023-04-17 11:42:56.476  INFO 1 --- [main] o.g.k.i.scheduler.SearchIndexController  : Lucene index version: 5

Komga version

0.161.0 (Truecharts)

Operating system

TrueNAS-SCALE-22.12.2

Other details

Running this application with my reverse proxy setup has been fine for a while now, but something changed with the recent truecharts changes. What I can't find is why the same fault occurs regardless of configuration method - removing and recreating the application.yml file, and switching between yml and environment variables nets the same result.

Setting context-path to '/' in the configuration (yml/env) works perfectly - the issue only occurs when there's an actual value entered into the option.

Note that I cannot update the app to the latest - that release is on the truecharts team. I intend to test further with a direct docker container deployment on truenas, as I find time.

Acknowledgements

gotson commented 1 year ago

Seems fine from logs:

2023-04-17 11:42:55.514  INFO 1 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path '/komga'

Could be an issue with the packaging you are using.

Berserkir-Wolf commented 1 year ago

I had a similar thought - truecharts appears to have lagged behind with updating their catalog build. Once I get a few minutes I intend to try docker direct and seeing if that works with the same variables set.

Berserkir-Wolf commented 1 year ago

I've just gone through testing with bind mounts in a pure docker scenario, rather than via truecharts - and the baseurl works perfectly in the application.yml file. Doesn't seem to apply in the environment variable, but I wouldn't be surprised if that's just me.

Fault appears to be with the truecharts implementation, not with the application. Closing issue.