Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support running behind reverse proxy under subdirectory #775

Open
1 of 2 tasks
gyuri-szing opened this issue Dec 24, 2024 · 2 comments
Open
1 of 2 tasks
Assignees

Comments

@gyuri-szing
Copy link

Description
When running lubelogger under a "subdirectory" behind a reverse proxy the application should generate URLs below a specific base URL. I am kindly asking for a new feature allowing to configure this base url.

E.g. if the proxy serves the app at http://192.168.0.2/lubelogger/ then e.g. the following app file /lib/bootstrap/dist/css/bootstrap.min.css should be accessed under http://192.168.0.2/lubelogger/lib/bootstrap/dist/css/bootstrap.min.css. If the application can not generate the correct URL, the proxy needs to do fragile app specific rewrites. Such rewrites may collide with other applications.

Why using "subdirectory" instead of a sub URL (e.g. lubelogger.my-server.lan)?
Because my home server is only accessible locally and I would like to avoid the complexity of setting up and managing a DNS server. mDNS and the .local domain does not work reliably with all OSs and thus I use the servers IP address to connect.

The reverse proxy is used fo convenience:

  • to avoid needing a certificate for each hosted application
  • to hide port number behind easier to remember names (e.g. 192.168.0.2:8006 vs 192.168.0.2/lubelogger)

Implementation options
I am far from a web developer or a HTTP expert, but at a quick glance there is no standard way to handle this issue. Applications usually either implement some configuration option to allow specifying a base URL, or react to HTTP headers.

The former could be implemented by adding the new BASE_URL option, possibly implemented as an environment variable.

The latter might be more portable, as the parameter would be configured at the same layer where the HTTP access is configured. Thus the application would be able to respond to direct and forwarded requests with the same app config.
AFAIK these are the de-facto standard HTTP headers being used in the wild:

  • X-Forwarded-Prefix Non-standard HTTP header.
  • X-Script-Name Non-standard HTTP header, but still widely used. Could not find a definitive documentation source. This one probably originates from CGI and WSGI.
  • Forwarded Standard HTTP header, but does not support a standard parameter to set the base URL. E.g. prefix=<base url> could work.

Platform

  • Docker Image
  • Windows Standalone Executable

Further data

  • LubeLogger version 1.4.1
  • Nginx version v1.19 (used as reverse proxy)

Example Nginx config:

server {
  listen        443 ssl;
  server_name   192.168.0.2;
  ssl_certificate     /etc/ssl/192.168.0.2-cert.pem;
  ssl_certificate_key /etc/ssl/192.168.0.2-key.pem;

  location ^~ /lubelogger/ {
    proxy_pass http://lubelogger:8080/;
    client_max_body_size               50000M;
    proxy_request_buffering off;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_http_version 1.1;
    proxy_set_header   Upgrade    $http_upgrade;
    proxy_set_header   Connection "upgrade";
    proxy_redirect off;
  }
}

Note: I am aware of #131 but this request is for a currently unsupported specific use-case.

@spystrach
Copy link

Hi all, i'm having the same issue running lubelogger with traefik (on Docker). An option in the "userConfig.json" file or an environment variable to set up a custom "http_root" will be much appreciated.

@gardiol
Copy link

gardiol commented Jan 25, 2025

Thank you, yes, this is also my use case... Hope there is hope for this feature :)

@hargata hargata self-assigned this Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants