AndrewPaglusch / FlashPaper

One-time encrypted password/secret sharing
MIT License
374 stars 60 forks source link

Configure generated links to use full domain instead of private hostame? #94

Closed hunsbct closed 1 year ago

hunsbct commented 1 year ago

I'm running the application in a docker container and had no issues getting it to work via reverse proxy, but the links that are being generated are using the hostname and mapped port instead of the full domain. So for example, the site is https://website.com/flashpaper but the URL is http://hostname:8989/?k=abcdef...

I am not seeing any information on how to configure the software to use a specific server or domain name for the generated URLs. Is this currently implemented?

AndrewPaglusch commented 1 year ago

Hey @hunsbct, thanks for reaching out! I helped someone else with a similar problem here: #60. That might help you figure this out. What reverse proxy are you using in front of FlashPaper?

hunsbct commented 1 year ago

I'm using nginx, and coincidentally landed on the same host header solution just before I came back here. That's getting me much closer, but now my URLs are coming up as https://website.com/?k=abcdef rather than https://website.com/flashpaper/?k=abcdef

I'm trying to see if there's a way at the nginx layer to add the /flashpaper slug but that may not be possible

AndrewPaglusch commented 1 year ago

Can you try changing location / { to location /flashpaper/ { in Nginx to see if that makes any difference? If not, I'm going to try to replicate your setup locally and figure it out for you. Also, try adding /flashpaper/ to the end of your proxy_pass line.

hunsbct commented 1 year ago

Sorry, I should have included that before. It currently is using that location:

location /flashpaper/ {
    proxy_pass http://hostname:8989/;
    proxy_set_header Host $host;
}

I appreciate your help so far. Let me know if there's any other info or testing I can assist with. Ultimately we could probably just use a subdomain for this if need be.

hunsbct commented 1 year ago

Quick addition, I did try adding /flashpaper to the end of the proxy_pass line as well as at the end of the proxy_set_header line, both of which break access to the application itself. The former will fail because the docker server is serving it on port 8989 without the URL slug, and the latter presumably because it's trying to reach https://website.com/flashpaper/flashpaper behind the scenes.

Not that I'm proficient enough with PHP or this project specifically to say for sure, but I'm thinking that one approach could be to add a "host" option to the docker-compose that overrides the HTTP_HOST detection in index.php

AndrewPaglusch commented 1 year ago

@hunsbct I've been thinking about implementing an override setting like that. It would allow the user to set the FQDN and path that should be used when creating the retrieval URL. If the setting is not set, FlashPaper will default to the current behavior of automatically generating the URL based on the information it has available.

I still would like to figure out the problem you're having, but I will probably end up adding this feature as well to make it easier for people to fix in the future.

AndrewPaglusch commented 1 year ago

Hey @hunsbct, @joshuanave and I just spent multiple hours tonight trying to find an elegant fix to this problem. We ultimately decided that the best way to correct this problem is to add the feature I mentioned in my last comment. Please see if v2.1.0 solves your problem.

hunsbct commented 1 year ago

Resolved! Thanks for taking the time to add this feature.

AndrewPaglusch commented 1 year ago

You're very welcome!