Skip to content

v1.2.0 breaks reverse proxy config when using INVENTREE_WEB_PORT #11339

Closed

Description

@p-fruck

Please verify that this bug has NOT been raised before.

  • I checked and didn't find a similar issue

Describe the bug*

#10900 introduced a new feature to modify the inventree server bind URL. For my setup this change was breaking and I wanted to ask whether this is something that should be fixed or something that should be ignored and the server admin is responsible for in your opinion.

Steps to Reproduce

I am using the standard docker-compose setup and changed the INVENTREE_WEB_PORT to 8080 because my InvenTree runs behind a separate proxy that handles TLS. With the new change, the InvenTree Server recognizes the variable to listen on port 8080, but my reverse proxy still proxies to the static 8080 port as this directive in the caddyfile ensures:

reverse_proxy {$INVENTREE_SERVER:"http://inventree-server:8000"}

Using the default setup and changing the INVENTREE_WEB_PORT to 8080 should be sufficient to produce a bad gateway error

Expected behaviour

I would expect that the reverse proxy also adapts to the new INVENTREE_WEB_PORT value.

Since caddy does not support nesting variable substitions (to my knowledge), I could not simply define

reverse_proxy {$INVENTREE_SERVER:"http://inventree-server:${INVENTREE_WEB_PORT:-8000}"}

as this leads to a syntax error.

My workaround was to use the following in my .env file:

INVENTREE_WEB_PORT=8080
INVENTREE_SERVER=http://inventree-server:${INVENTREE_WEB_PORT}

Now this is not a big deal for admins, just something to be aware of. Is it worth considering a fix in the setup? Or is it simply the server admins responsibility?

Deployment Method

Docker

Version Information

v1.2.0

Try to reproduce on the demo site

I did not try to reproduce

Is the bug reproducible on the demo site?

Not reproducible

Relevant log output

Activity

  1. added
    bug
    question
    triage:not-checked
    on Feb 16, 2026
  2. SchrodingersGat commented on Feb 16, 2026

    @SchrodingersGat
    Member

    The provided setup files do not provide (and cannot provide) a one-size-fits-all solution. I think that this is fine and not a "bug" - the server admin can easily edit the file as needed, and overwrite the placeholders.

  3. added
    wontfix
    setup
    and removed
    bug
    triage:not-checked
    on Feb 16, 2026
  4. p-fruck commented on Feb 16, 2026

    @p-fruck
    ContributorAuthor

    Fine more me, thanks for the reply 👍

  5. self-assigned this
    on Feb 16, 2026
  6. matmair commented on Feb 17, 2026

    @matmair
    Member

    @p-fruck would this help? #11352

  7. p-fruck commented on Feb 17, 2026

    @p-fruck
    ContributorAuthor

    @matmair this results in the following error for me:

    inventree-proxy  | Error: adapting config using caddyfile: parsing caddyfile tokens for 'handle_path': parsing caddyfile tokens for 'forward_auth': parsing upstream 'http://inventree-server:8080"}': parsing upstream URL: parse "http://inventree-server:8080"}": port range invalid: 8080"}, at /etc/caddy/Caddyfile:65, at /etc/caddy/Caddyfile:68
    

    As mentioned in the issue description, I don't think caddy supports nested variables. We could however fix the default behavior using docker-compose if we add the following:

    services:
      inventree-worker:
        expose: # not actually required, just metadata
          - ${INVENTREE_WEB_PORT:-8000}
      inventree-proxy:
        env_file:
          - .env
        environment:
          INVENTREE_SERVER: http://inventree-server:${INVENTREE_WEB_PORT}

    Only the environment section is new. This way we would ensure caddy still works when the INVENTREE_WEB_PORT is changed. Since the .env file takes precendence, the INVENTREE_SERVER variable can still be overridden using .env.

    Still, I would like to leave the decision up to you whether you want to handle this special case or just delegate the responsibility to the server admins :)

  8. gid204 commented on Feb 17, 2026

    @gid204

    Thanks for this, I already had INVENTREE_WEB_PORT=8080 in my .env but adding INVENTREE_SERVER=http://inventree-server:${INVENTREE_WEB_PORT} has fixed the issue for me.

    Is someone able to explain what this line is actually doing and why it resolves the issue?

  9. p-fruck commented on Feb 17, 2026

    @p-fruck
    ContributorAuthor

    I think this issue already explains it?

    • The reverse proxy proxies either http://inventree-server:8000 or ${INVENTREE_SERVER} if this variable is defined (by default it isn't)
    • Your inventree-server runs on 8000 by default
    • With [Docker] Allow gunicorn webserver bind address to be adjusted #10900 the inventree-server started listening on INVENTREE_WEB_PORT if defined (instead of 8000)
    • The reverse proxy does not automatically adapt to the new port and still proxies http://inventree-server:8000 (nothing is running on this port however)
    • By using INVENTREE_SERVER=http://inventree-server:${INVENTREE_WEB_PORT} you simply tell the reverse proxy to dynamically adapt to the INVENTREE_WEB_PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

questionsetupwontfix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions