sendria icon indicating copy to clipboard operation
sendria copied to clipboard

[Feature Request] Add configuration option to allow subpath for the webserver

Open allangood opened this issue 3 years ago • 6 comments

First of all, thank you for your great work!

I am working in a way to add a configuration option (--webpath) to allow the web interface to be hosted in a subpath, like "/sendria". This is particular important for me as I would like to run it behind a reverse proxy with multiple other projects.

I am opening this request for a future PR.

Thank you.

allangood avatar Mar 10 '21 03:03 allangood

Hello @allangood

Thank you for your proposal! It may take some time, however I think it's worth to add. I'll try to start working on it in a while.

msztolcman avatar Mar 15 '21 09:03 msztolcman

I have the same requirement. Looking forward to your PR :-)

sbusch avatar Apr 22 '21 15:04 sbusch

Hi guys, I've already started work on it. I've already finished with hardest (from my point of view) part, I mean frontend ;) And now need to find some time for backend and polishing. Hope will find and finish soon.

msztolcman avatar Apr 22 '21 19:04 msztolcman

Hi @sbusch, @allangood ,

I just pushed some initial, but mostly working version of sendria, which can work in subpath. You can install it using pip:

pip install git+https://github.com/msztolcman/sendria.git@non-root-ui-sendria

It requires new param when starting sendria, i.e.: --http-url-prefix /asd/

And slighlty modified nginx config (rewrite pragma), you can see whole config in https://github.com/msztolcman/sendria/blob/non-root-ui-sendria/addons/nginx-non-root.conf

Can you take a look is this working fine or not? I will try to test it more in few days, however other pair of eyes would be very useful :)

msztolcman avatar May 06 '21 22:05 msztolcman

Hello @msztolcman ,

Thank you for your update!

I've tried to build but couldn't build the assets:

/home/sendria/.local/bin/webassets -m sendria.build_assets build
Traceback (most recent call last):
  File "/home/sendria/.local/bin/webassets", line 8, in <module>
    sys.exit(run())
  File "/home/sendria/.local/lib/python3.9/site-packages/webassets/script.py", line 578, in run
    sys.exit(main(sys.argv[1:]) or 0)
  File "/home/sendria/.local/lib/python3.9/site-packages/webassets/script.py", line 572, in main
    return GenericArgparseImplementation(env).main(argv)
  File "/home/sendria/.local/lib/python3.9/site-packages/webassets/script.py", line 557, in main
    return self.run_with_argv(argv)
  File "/home/sendria/.local/lib/python3.9/site-packages/webassets/script.py", line 549, in run_with_argv
    return self.run_with_ns(ns)
  File "/home/sendria/.local/lib/python3.9/site-packages/webassets/script.py", line 531, in run_with_ns
    env = self._setup_assets_env(ns, log)
  File "/home/sendria/.local/lib/python3.9/site-packages/webassets/script.py", line 509, in _setup_assets_env
    env = PythonLoader(ns.module).load_environment()
  File "/home/sendria/.local/lib/python3.9/site-packages/webassets/loaders.py", line 272, in __init__
    self.module = import_module(module_name)
  File "/home/sendria/.local/lib/python3.9/site-packages/webassets/importlib.py", line 36, in import_module
    __import__(name)
  File "/home/sendria/.local/lib/python3.9/site-packages/sendria/build_assets.py", line 4, in <module>
    environment = configure_assets(False, False)
  File "/home/sendria/.local/lib/python3.9/site-packages/sendria/http/core.py", line 272, in configure_assets
    assets = webassets.Environment(directory=config.STATIC_DIR, url=config.CONFIG.url_static)
AttributeError: 'NoneType' object has no attribute 'url_static'

Am I missing something?

allangood avatar May 14 '21 21:05 allangood

Hi @allangood,

I missed some problems with running webassets manually. It's not related to this issue, will fix this later. Please run sendria with -a switch, then it should automatically create assets. This works fine on newly created vps. Also, I've updated nginx config, now it works with url's without trailing /.

msztolcman avatar May 27 '21 11:05 msztolcman