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: custom web-root #35

Closed
gotschi opened this issue Jun 8, 2022 · 15 comments
Closed

Feature Request: custom web-root #35

gotschi opened this issue Jun 8, 2022 · 15 comments
Labels
enhancement New feature or request

Comments

@gotschi
Copy link

gotschi commented Jun 8, 2022

I use a reverse proxy in my DMZ to forward pages from my internal net to WWW.

If I want to put this page onto domain.tld/start and have it proxy to jump:8123/ it requests the underlying sources wrong with "/" being the webroot.
So instead of domain.tld/start/background.php it requests domain.tld/background.php

Which of course fails

@daledavies daledavies added the bug Something isn't working label Jun 8, 2022
@daledavies
Copy link
Owner

daledavies commented Jun 8, 2022

Interesting, thanks for letting me know. I'll see if I can recreate your reverse proxy scenario (as I currently use subdomains rather than directories) and think about ways to address this. Possibly an optional subdirectory or wwwroot config option.

@daledavies daledavies added enhancement New feature or request and removed bug Something isn't working labels Jun 8, 2022
@gotschi
Copy link
Author

gotschi commented Jun 8, 2022

That is usually the case, that apps get proxied per subdomain.
In which case this is not needed.

(I'm also using a wildcard cert which exposes all eventual other subdomains,
so I like to keep that at 1 domain because it's easier to surveil attacks etc..)

anyways, great landing page I really like the simplicity!

EDIT: I just removed all absolute references "/" in templates, classes/Background.php
and it seems to work fine except for the tag referncing which i can redirect at the proxy level

@daledavies
Copy link
Owner

Yeah that's the reason I went with the absolute URLs in the templates. I'm thinking a wwwroot option might be the best way forward, then I can prefix URLs with that in the templates.

@daledavies
Copy link
Owner

I've added an option for this in v1.2.2 (released today). You can now configure a custom URL via the WWWURL environment variable (if using Docker) or the wwwurl parameter in config.php.

Thank you again for reaching out :)

@gotschi
Copy link
Author

gotschi commented Jul 1, 2022

awesome, thank you!

however, i tried to pull :latest from docker-hub and also :v1.2.2 but it seems I cant get the current one - maybe the CDNs need some time.

anyways thank you for taking care of it!!

@gotschi
Copy link
Author

gotschi commented Jul 3, 2022

Seems like the wwwroot parameter is still missing in L40 classes/Background.php
and also in the static compiled JS assets/js/src/classes/Weather.js

and they also don't get used with docker environments, had to rewrite config.php

@daledavies
Copy link
Owner

Thanks for sticking around and coming back to test this, really appreciated! Unfortunately I'm not able to recreate your setup locally so wasn't able to test properly myself.

I have fixed Background.php and Weather.js, plus corrected the docker environment variable issue.

Are you able to pull the main branch and test that , would save a bit of time, or do you need me to make a docker image?

@daledavies daledavies reopened this Jul 4, 2022
@gotschi
Copy link
Author

gotschi commented Jul 4, 2022

so I used following docker-compose and mapped the repo to /var/www/html

        volumes:
            - ./jump/jumpapp:/var/www/html
            - ./backgrounds:/backgrounds
            - ./search:/search
            - ./sites:/sites
        environment:
            SITENAME: '#home'
            OWMAPIKEY: 'redacted'
            LATLONG: 'xxx.xxxxx,xxx.xxxxx'
            NOINDEX: 'true'
            SHOWGREETING: 'false'
            WWWURL: '/jump'
            CACHEBYPASS: 'true'

and I can't get it to work, even with /jump manually put in config - background and weaterdata.php fail to load (because the js is not compiled?)

anyway I also tried building the container but have no display on my machine :/
error: failed to solve: failed to solve with frontend dockerfile.v0: failed to create LLB definition: rpc error: code = Unknown desc = error getting credentials - err: exit status 1, out: Cannot autolaunch D-Bus without X11 $DISPLAY``

I never did multiarch builds before

so I'm not much of a help here,
In case for apache however it's a simple vhost < Location > entry to get such pages on a custom slug, I guess nginx is even easier:

	<Location /jump>
		ProxyPass http://127.0.0.1:9090/
		ProxyPassReverse http://127.0.0.1:9090/
        </Location>

@daledavies
Copy link
Owner

daledavies commented Jul 4, 2022

I'd intended that you should put the full URL including domain (e.g. https://yourdomain.com/start), but will need to do some testing with an actual proxy in place to understand why what you have got isn't working as I think it should.

The compiled javascript bundle should be in place already as I bundled it before committing.

Check that the web root directory hasn't been overwritten when you started the container, maybe stop the container and add the DEVELOPMENT: 'true' environment variable to docker-compose, then pull the main branch again before bringing the container back up. The development variable isn't documented, but it stops the container entrypoint moving things around on startup.

@daledavies
Copy link
Owner

I'll have a play around over the next few days anyway and see if I can work out why it isn't working for you 😀

@daledavies
Copy link
Owner

daledavies commented Jul 5, 2022

I set up two tests using the latest commit from main and both do seem to work as expected.

The first was to copy everything from within the jumpapp directory into jumpapp/test and then set WWWURL to /test.

The second was to use an nginx reverse proxy with the following nginx config and WWWURL set to /test...

server {

	listen 80;

	location /test/ {

		proxy_pass         http://web:8080/;
		proxy_redirect     off;
		proxy_set_header   Host $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-Host $server_name;
	}
}

I've pushed a new image to docker hub for you to test the latest commit... daledavies/jump:wwwurl-fix.

Let me know how you get on, thanks again :)

@daledavies
Copy link
Owner

If this works I'll create a new release with the patch and update the documentation to clarify use of the WWWURL option.

@gotschi
Copy link
Author

gotschi commented Jul 5, 2022

yup, the :wwwurl-fix tag works fine! very nice!

I have found the DEVELOPMENT: 'true' environment var makes nginx fail, maybe there is something more to set up but running it without works as intended!

Feature successfully added!

Edit: the Tags need some refinements too it seems, the /wwwurl/tag pages come without styles.
But for me that is plenty enough I don't use the tags :)

@gotschi gotschi closed this as completed Jul 5, 2022
@daledavies
Copy link
Owner

So close, must admit I didn't test the tag pages yet!

I'll take a look tomorrow. It'll be something simple, at least now I have a way of testing it.

Thanks again for your help 😀

@daledavies
Copy link
Owner

I found the problem and fixed it! I've packaged everything into the latest release (v1.2.3), you should be able to pick this up from Docker Hub now using the v.1.2.3 or latest tags.

Thanks again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants