Closed rippiedoos closed 4 years ago
Hello,
Unfortunately that's not supported right now. I pushed an experimental branch at https://github.com/powa-team/powa-web/tree/url_prefix which should allow you to set a new parameter "url_prefix" (default is /
) in the config file.
Be warned, I don't know much about tornado, so it may break in random places. A quick local test showed that most of the stuff was working though. Note also that this is for the 4.x version, but it should be easy to adapt for another branch you might be using.
Ah thank you! Will this be a feature for 4.x?
If you can test and validate that it's working as expected, I'll definitely include it in v4 yes :)
I've monkey-patched my 3.2-install and I'm getting the following error, so not that successful yet :
Traceback (most recent call last):
File "/bin/powa-web", line 9, in <module>
application = make_app(debug=False, gzip=True, compress_response=True)
File "/usr/lib/python2.7/site-packages/powa/__init__.py", line 56, in make_app
parse_options()
File "/usr/lib/python2.7/site-packages/powa/options.py", line 72, in parse_options
options['url_prefix'] = "/" + options['url_prefix'].strip("/") + "/"
TypeError: 'OptionParser' object does not support item assignment
And I think you missed line 78 in __init__.py
:
login_url="/login/",
I'm running powa-web 3.2.0 from the PostgreSQL11 RPM-distro on CentOS by the way on python 2.7.5.
Thanks, I pushed a fix for the /login page.
I tried using python 2.7, and it's working fine AFAICT:
grep url_prefix powa-web.conf
url_prefix="/toto"
$ ./powa-web
[I 190802 17:19:07 powa-web:13] Starting powa-web on http://127.0.0.1:8080/toto/
[I 190802 17:19:09 web:2162] 302 GET /toto/ (127.0.0.1) 22.73ms
[I 190802 17:19:09 web:2162] 304 GET /toto/server/ (127.0.0.1) 38.93ms
[I 190802 17:19:10 web:2162] 200 GET /toto/server/all_servers/?from=2019-08-02+16%3A19%3A10%2B0200&to=2019-08-02+17%3A19%3A10%2B0200 (127.0.0.1) 14.99ms
[...]
I'm not sure how to reproduce your issue locally.
Thanks so far. A need some time to take a look at this further. One problem I already spotted is the static content, where all the JavaScript and CSS lives. They reference the URL's all bij /static/. Maybe a good idea to include a base href in the HTML-pages and switch to static/
as static-URL? I didn't have time to look at it properly so maybe it's a non-issue.
Good point. This can apparently be fixed with the static_url_prefix
tornado setting, provided that all content go through {{static_url()}}
calls. It seems to be the case after a quick look.
I pushed a fix for that.
And how about line 2 in config.js?
config.js is only used in debug mode: https://github.com/powa-team/powa-web/blob/master/powa/templates/layout.html#L128
This mode is usually using for testing by developers using run_powa.py (https://github.com/powa-team/powa-web/blob/master/run_powa.py#L7) and shouldn't be used in production so it shouldn't be a problem.
That being said, it seems that simply dropping the baseUrl key in config.js fixes the problem for debug mode, whether a url_prefix is specified or not, and the doc confirm that if should be safe to do so as w're using data-main attribute. I'd vote for removing that from config.js.
I'm back to reviewing the changes and 2 things that need fixes in my situation (powa-3.2 on RHEL7):
Line 48 in __init__.py
U(r"%slogout/ % options.url_prefix", LogoutHandler, name="logout"),
The quotation mark after url_prefix
should be after %slogout/
U(r"%slogout/" % options.url_prefix, LogoutHandler, name="logout"),
And if I click on the logout-link, I get redirected to the URL /
(and gives me a 403, but that is fixable). I don't know if there is a target-URL that can be configured after the logout-event or that I need to revise my monkey-patching. But this last thing (logout-URL) seems the last thing.
Any chance of looking at the above 'fix'?
I'm really sorry I totally forgot about that :(
I just rebased the url_prefix branch and fixed the issue you spotted and the logout handler. I did some testing and as far as I can tell everything is now working (except the JS part when running in debug mode but I have no idea on how to fix it, and it's not that a problem I think).
Could you test it further and see if you find any other issues? If not I'll be glad to merge it in master so it'll be available in upcoming v4.
Yes, works like a charm! Thanks a lot! From my point of view, this is now fixed.
Great thanlks a lot!
I just merged it in the master branch!
I'm trying to run PoWA Web behind a reverse proxy, with Apache Form Auth, under a context root.
Is there a way for PoWA-web to not run under the context root / but under /powa/ so all URL's start with /powa/ (or some other prefix)?
I've tried mod-rewrite with various rewrite's but that didn't work. Also adapting the script-alias for the WSGI-application from / to /powa/ didn't work. Help?