Can't make sub-paths work #14

Closed
opened 2026-09-07 13:26:44 +03:00 by shimitar · 6 comments

URL: https://domain.com/printer

My docker-compose:

services:
  webprint:
    image: forged.hel.alfredolin.eu/webprint:latest
    ports:
      - "3311:3001"
    environment:
      - PORT=3001
      - JWT_SECRET=xxx
      - PRINTER_NAME=xxx
      - ADMIN_USER=xxx
      - ADMIN_PASS=xxx
      - DEBUG_ERRORS=true
      - GIN_MODE=test
      - HOST_URL=https://comain.com/printer
      - LP_GID=7
    volumes:
      - ./db:/data
      - ./tmp-printing:/tmp/printing-app
      - /run/cups:/run/cups
    restart: unless-stopped
#    depends_on:
#      - cups
    networks:
      - webprint-net

My nginx relevant section:


location = /printer {
        return 301 https://$host/printer/;
}

# Interfaccia Web stmapante HP
location /printer/ {
        proxy_pass http://127.0.0.1:3311/;
}

In the logs i see:

[webprint] | 2026/09/07 10:25:12 Warning: APPRISE_URL not set — notifications disabled
[webprint] | 2026/09/07 10:25:12 Warning: HOST_URL is https:// — cookies will be marked Secure.
[webprint] | 2026/09/07 10:25:12 Warning: Clients MUST reach the app over HTTPS (e.g. reverse proxy with TLS),
[webprint] | 2026/09/07 10:25:12 Warning: otherwise browsers silently drop the session cookie and login will loop.
[webprint] | 2026/09/07 10:25:12 === Configuration ===
[webprint] | 2026/09/07 10:25:12 Port: 3001
[webprint] | 2026/09/07 10:25:12 Printer: 
[webprint] | 2026/09/07 10:25:12 Debug: true
[webprint] | 2026/09/07 10:25:12 Apprise: false
[webprint] | 2026/09/07 10:25:12 Max file age: 24h
[webprint] | 2026/09/07 10:25:12 Rate limit: 15/min
[webprint] | 2026/09/07 10:25:12 Max login attempts: 5
[webprint] | 2026/09/07 10:25:12 Host URL: https://domain.com/printer
[webprint] | 2026/09/07 10:25:12 Base path: /printer
[webprint] | 2026/09/07 10:25:12 Secure cookies: true
[webprint] | 2026/09/07 10:25:12 OIDC: false
[webprint] | 2026/09/07 10:25:12 =====================
[webprint] | 2026/09/07 10:25:12 WebPrint version: 1.0.7
[webprint] | 2026/09/07 10:25:12 [DB] User count: 1
[webprint] | 2026/09/07 10:25:12 [DB] Users already exist, skipping admin seed
[webprint] | 2026/09/07 10:25:12 Database initialized at /data/print.db
[webprint] | 2026/09/07 10:25:12 🌐 Loaded locale: en (174 keys)
[webprint] | 2026/09/07 10:25:12 🌐 Loaded locale: fr (174 keys)
[webprint] | 2026/09/07 10:25:12 🌐 Loaded locale: de (174 keys)
[webprint] | 2026/09/07 10:25:12 🌐 Loaded locale: fi (174 keys)
[webprint] | 2026/09/07 10:25:12 Syncing printers with CUPS...
[webprint] | 2026/09/07 10:25:12 [CUPS] Starting printer sync...
[webprint] | 2026/09/07 10:25:12 [CUPS] Discovered 1 printers, default: xxx
[webprint] | 2026/09/07 10:25:12 [CUPS] Processing printer: xxx (enabled=true, default=true, location=)
[webprint] | 2026/09/07 10:25:12 [CUPS] lpoptions for xxx produced stderr: lpoptions: Unable to get PPD file for xxx: No printer-uri found
[webprint] | 2026/09/07 10:25:12 [CUPS] Updated printer: xxx
[webprint] | 2026/09/07 10:25:12 [CUPS] Sync complete: 1 printers discovered, 1 in database
[webprint] | 2026/09/07 10:25:12 [Cleanup] Started: removing files older than 24h from /tmp/printing-app
[webprint] | 2026/09/07 10:25:12 🚀 Server starting on :3001 (base path: "/printer")


[webprint] | [GIN] 2026/09/07 - 10:25:37 | 404 |      39.895µs |       10.89.0.2 | GET      "/"

and in borwser i get a 404 page not found, from the app itself (not from nginx).

URL: https://domain.com/printer My docker-compose: ``` services: webprint: image: forged.hel.alfredolin.eu/webprint:latest ports: - "3311:3001" environment: - PORT=3001 - JWT_SECRET=xxx - PRINTER_NAME=xxx - ADMIN_USER=xxx - ADMIN_PASS=xxx - DEBUG_ERRORS=true - GIN_MODE=test - HOST_URL=https://comain.com/printer - LP_GID=7 volumes: - ./db:/data - ./tmp-printing:/tmp/printing-app - /run/cups:/run/cups restart: unless-stopped # depends_on: # - cups networks: - webprint-net ``` My nginx relevant section: ``` location = /printer { return 301 https://$host/printer/; } # Interfaccia Web stmapante HP location /printer/ { proxy_pass http://127.0.0.1:3311/; } ``` In the logs i see: ``` [webprint] | 2026/09/07 10:25:12 Warning: APPRISE_URL not set — notifications disabled [webprint] | 2026/09/07 10:25:12 Warning: HOST_URL is https:// — cookies will be marked Secure. [webprint] | 2026/09/07 10:25:12 Warning: Clients MUST reach the app over HTTPS (e.g. reverse proxy with TLS), [webprint] | 2026/09/07 10:25:12 Warning: otherwise browsers silently drop the session cookie and login will loop. [webprint] | 2026/09/07 10:25:12 === Configuration === [webprint] | 2026/09/07 10:25:12 Port: 3001 [webprint] | 2026/09/07 10:25:12 Printer: [webprint] | 2026/09/07 10:25:12 Debug: true [webprint] | 2026/09/07 10:25:12 Apprise: false [webprint] | 2026/09/07 10:25:12 Max file age: 24h [webprint] | 2026/09/07 10:25:12 Rate limit: 15/min [webprint] | 2026/09/07 10:25:12 Max login attempts: 5 [webprint] | 2026/09/07 10:25:12 Host URL: https://domain.com/printer [webprint] | 2026/09/07 10:25:12 Base path: /printer [webprint] | 2026/09/07 10:25:12 Secure cookies: true [webprint] | 2026/09/07 10:25:12 OIDC: false [webprint] | 2026/09/07 10:25:12 ===================== [webprint] | 2026/09/07 10:25:12 WebPrint version: 1.0.7 [webprint] | 2026/09/07 10:25:12 [DB] User count: 1 [webprint] | 2026/09/07 10:25:12 [DB] Users already exist, skipping admin seed [webprint] | 2026/09/07 10:25:12 Database initialized at /data/print.db [webprint] | 2026/09/07 10:25:12 🌐 Loaded locale: en (174 keys) [webprint] | 2026/09/07 10:25:12 🌐 Loaded locale: fr (174 keys) [webprint] | 2026/09/07 10:25:12 🌐 Loaded locale: de (174 keys) [webprint] | 2026/09/07 10:25:12 🌐 Loaded locale: fi (174 keys) [webprint] | 2026/09/07 10:25:12 Syncing printers with CUPS... [webprint] | 2026/09/07 10:25:12 [CUPS] Starting printer sync... [webprint] | 2026/09/07 10:25:12 [CUPS] Discovered 1 printers, default: xxx [webprint] | 2026/09/07 10:25:12 [CUPS] Processing printer: xxx (enabled=true, default=true, location=) [webprint] | 2026/09/07 10:25:12 [CUPS] lpoptions for xxx produced stderr: lpoptions: Unable to get PPD file for xxx: No printer-uri found [webprint] | 2026/09/07 10:25:12 [CUPS] Updated printer: xxx [webprint] | 2026/09/07 10:25:12 [CUPS] Sync complete: 1 printers discovered, 1 in database [webprint] | 2026/09/07 10:25:12 [Cleanup] Started: removing files older than 24h from /tmp/printing-app [webprint] | 2026/09/07 10:25:12 🚀 Server starting on :3001 (base path: "/printer") [webprint] | [GIN] 2026/09/07 - 10:25:37 | 404 | 39.895µs | 10.89.0.2 | GET "/" ``` and in borwser i get a 404 page not found, from the app itself (not from nginx).
Author

Local access (127.0.0.1:3311/printer/) works

Local access (127.0.0.1:3311/printer/) works
Author

I see in browser debug window that there is a GET to https://domain.com/printer/login and this is the 404

I see in browser debug window that there is a GET to https://domain.com/printer/login and this is the 404
Author

Some app logs for the tests i did:

[webprint] | [GIN] 2026/09/07 - 10:25:37 | 404 |      39.895µs |       10.89.0.2 | GET      "/"
[webprint] | [GIN] 2026/09/07 - 10:27:10 | 404 |       9.328µs |       10.89.0.2 | GET      "/print"
[webprint] | [GIN] 2026/09/07 - 10:27:10 | 404 |       7.154µs |       10.89.0.2 | GET      "/favicon.ico"
[webprint] | [GIN] 2026/09/07 - 10:27:12 | 404 |     274.667µs |       10.89.0.2 | GET      "/print"
[webprint] | [GIN] 2026/09/07 - 10:27:12 | 404 |       9.328µs |       10.89.0.2 | GET      "/print"
[webprint] | [GIN] 2026/09/07 - 10:27:18 | 302 |       26.07µs |       10.89.0.2 | GET      "/printer/"
[webprint] | 2026/09/07 10:27:18 [Auth] Cookie err: <nil>, token length: 153
[webprint] | 2026/09/07 10:27:18 [Auth] Valid token for user: admin
[webprint] | [GIN] 2026/09/07 - 10:27:18 | 200 |    1.288476ms |       10.89.0.2 | GET      "/printer/print"
[webprint] | [GIN] 2026/09/07 - 10:27:19 | 200 |     210.667µs |       10.89.0.2 | GET      "/printer/static/style.css"
[webprint] | [GIN] 2026/09/07 - 10:27:19 | 200 |      76.173µs |       10.89.0.2 | GET      "/printer/static/logo-dark.svg"
[webprint] | [GIN] 2026/09/07 - 10:27:29 | 404 |       7.574µs |       10.89.0.2 | GET      "/"
[webprint] | [GIN] 2026/09/07 - 10:27:39 | 302 |      32.371µs |       10.89.0.2 | GET      "/printer/"
[webprint] | [GIN] 2026/09/07 - 10:27:39 | 404 |       4.208µs |       10.89.0.2 | GET      "/print"
[webprint] | 2026/09/07 10:28:08 [Auth] Cookie err: http: named cookie not present, token length: 0
[webprint] | 2026/09/07 10:28:08 [Auth] Token parse failed: http: named cookie not present
[webprint] | 2026/09/07 10:28:08 [Auth] Token parse failed: token is malformed: token contains an invalid number of segments
[webprint] | 2026/09/07 10:28:08 [Auth] Valid token for user: 
[webprint] | 
[webprint] | 2026/09/07 10:28:08 /app/auth.go:82 record not found
[webprint] | [0.284ms] [rows:0] SELECT * FROM `users` WHERE username = "" ORDER BY `users`.`id` LIMIT 1
[webprint] | [GIN] 2026/09/07 - 10:28:08 | 302 |     399.903µs |       10.89.0.2 | GET      "/printer/print"
[webprint] | 2026/09/07 10:28:08 [Auth] Failed to fetch user : record not found
[webprint] | [GIN] 2026/09/07 - 10:28:08 | 404 |       8.546µs |       10.89.0.2 | GET      "/login"
[webprint] | [GIN] 2026/09/07 - 10:28:49 | 404 |       10.71µs |       10.89.0.2 | GET      "/login"
[webprint] | [GIN] 2026/09/07 - 10:30:27 | 404 |      24.967µs |       10.89.0.2 | GET      "/login"
[webprint] | [GIN] 2026/09/07 - 10:30:30 | 302 |      35.738µs |       10.89.0.2 | GET      "/printer/"
[webprint] | [GIN] 2026/09/07 - 10:30:30 | 404 |       4.348µs |       10.89.0.2 | GET      "/print"
Some app logs for the tests i did: ``` [webprint] | [GIN] 2026/09/07 - 10:25:37 | 404 | 39.895µs | 10.89.0.2 | GET "/" [webprint] | [GIN] 2026/09/07 - 10:27:10 | 404 | 9.328µs | 10.89.0.2 | GET "/print" [webprint] | [GIN] 2026/09/07 - 10:27:10 | 404 | 7.154µs | 10.89.0.2 | GET "/favicon.ico" [webprint] | [GIN] 2026/09/07 - 10:27:12 | 404 | 274.667µs | 10.89.0.2 | GET "/print" [webprint] | [GIN] 2026/09/07 - 10:27:12 | 404 | 9.328µs | 10.89.0.2 | GET "/print" [webprint] | [GIN] 2026/09/07 - 10:27:18 | 302 | 26.07µs | 10.89.0.2 | GET "/printer/" [webprint] | 2026/09/07 10:27:18 [Auth] Cookie err: <nil>, token length: 153 [webprint] | 2026/09/07 10:27:18 [Auth] Valid token for user: admin [webprint] | [GIN] 2026/09/07 - 10:27:18 | 200 | 1.288476ms | 10.89.0.2 | GET "/printer/print" [webprint] | [GIN] 2026/09/07 - 10:27:19 | 200 | 210.667µs | 10.89.0.2 | GET "/printer/static/style.css" [webprint] | [GIN] 2026/09/07 - 10:27:19 | 200 | 76.173µs | 10.89.0.2 | GET "/printer/static/logo-dark.svg" [webprint] | [GIN] 2026/09/07 - 10:27:29 | 404 | 7.574µs | 10.89.0.2 | GET "/" [webprint] | [GIN] 2026/09/07 - 10:27:39 | 302 | 32.371µs | 10.89.0.2 | GET "/printer/" [webprint] | [GIN] 2026/09/07 - 10:27:39 | 404 | 4.208µs | 10.89.0.2 | GET "/print" [webprint] | 2026/09/07 10:28:08 [Auth] Cookie err: http: named cookie not present, token length: 0 [webprint] | 2026/09/07 10:28:08 [Auth] Token parse failed: http: named cookie not present [webprint] | 2026/09/07 10:28:08 [Auth] Token parse failed: token is malformed: token contains an invalid number of segments [webprint] | 2026/09/07 10:28:08 [Auth] Valid token for user: [webprint] | [webprint] | 2026/09/07 10:28:08 /app/auth.go:82 record not found [webprint] | [0.284ms] [rows:0] SELECT * FROM `users` WHERE username = "" ORDER BY `users`.`id` LIMIT 1 [webprint] | [GIN] 2026/09/07 - 10:28:08 | 302 | 399.903µs | 10.89.0.2 | GET "/printer/print" [webprint] | 2026/09/07 10:28:08 [Auth] Failed to fetch user : record not found [webprint] | [GIN] 2026/09/07 - 10:28:08 | 404 | 8.546µs | 10.89.0.2 | GET "/login" [webprint] | [GIN] 2026/09/07 - 10:28:49 | 404 | 10.71µs | 10.89.0.2 | GET "/login" [webprint] | [GIN] 2026/09/07 - 10:30:27 | 404 | 24.967µs | 10.89.0.2 | GET "/login" [webprint] | [GIN] 2026/09/07 - 10:30:30 | 302 | 35.738µs | 10.89.0.2 | GET "/printer/" [webprint] | [GIN] 2026/09/07 - 10:30:30 | 404 | 4.348µs | 10.89.0.2 | GET "/print" ```
Owner

Your nginx config should put "printer" in the path too, as per README.md.

Try again with:

location /printer/ {
        proxy_pass http://127.0.0.1:3311/printer;
}
Your nginx config should put "printer" in the path too, as per README.md. Try again with: ```conf location /printer/ { proxy_pass http://127.0.0.1:3311/printer; } ```
Author

Ok i managed to fix my NGINX setup:

location /printer {
        proxy_pass http://127.0.0.1:3311/printer;
}

it is to be noted where the "/" goes, or better, must be avoided. This is a quick of NGINX setup, but pretty annoying. It probably stems from something inside the webprint app, because the above setup just works for a lot of other service. But it's ok, maybe you could add the nginx setup to the readme as well.

Ok i managed to fix my NGINX setup: ``` location /printer { proxy_pass http://127.0.0.1:3311/printer; } ``` it is to be noted where the "/" goes, or better, must be avoided. This is a quick of NGINX setup, but pretty annoying. It probably stems from something inside the webprint app, because the above setup just works for a lot of other service. But it's ok, maybe you could add the nginx setup to the readme as well.
Owner

Very good, writing previous comment I was also wondering about trailing slashes, but did not have the time to check it through.

I'll add it to the README.md, thank you!

Very good, writing previous comment I was also wondering about trailing slashes, but did not have the time to check it through. I'll add it to the README.md, thank you!
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Alfredolin/WebPrint#14
No description provided.