mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2026-02-03 14:13:26 +00:00
Support for customized subroute? #276
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lucernae on GitHub.
Hi! Love this work, @dutchcoders !
Transfer.sh is very easy to deploy and try.
I have some questions on this.
We are planning to use transfer.sh in our web apps as a subroute, in a sense like this:
Let's say I deployed a web app with domain:
domain.org, and accessible in this urlhttp://domain.org/.I would like to deploy transfer.sh in a subroute (because the web apps is a separate system), like this:
http://domain.org/transferto acces transfer.sh.I tried to reroute the traffic using haproxy, but it seems the html inside is bound to the route url. So to summarize, I have broken links for scripts, styles, etc, because it gives links to
http://domain.org/scriptsinstead ofhttp://domain.org/transfer/scripts.So, my question is, does this use case currently handled by transfer.sh?
If not, should I make PR to do that (I'm not too familiar with golang, so it might take time)?
@lucernae commented on GitHub:
Also, @aspacca are you the maintainer of this project now?
@paolafrancesca commented on GitHub:
hello @lucernae you're right
please test #206 branch and tell me if it fixes the problem
I tested only on UI side and it works
please, note that a new param --proxy-path is needed to instruct transfer.sh to build the proper redirect url
@lucernae commented on GitHub:
Thanks, for the quick follow up!
I ended up doing some modification (of course it's a hack :p), to make transfer.sh web shows the correct url and all the styles.
I'm not too confident with the code anyway, so I will test your branch code.
It's interesting to see the problem in issue #204 too since it was dealing with https terminated in the proxy.
I will check your branch with the X-Forwarded-Proto header set for https.
@paolafrancesca commented on GitHub:
@lucernae I started implementing #206 (and related branch in transfer.sh-web) trying to avoid to pass an explicit param for the proxy path and relying instead on relative paths and request rewriting in the proxy, until I realized I needed it to generate the download url: if it'd still find a way to do without it I'd prefer
I use nginx as proxy, and in my tests with subpath I made the equivalent configuration you did with haproxy removing the subpath when proxying to transfer.sh backend
the basic difference between our solutions is that I use the param only for build the output urls (in the frontend template and in the curl output, as long as for the
X-Delete-Urlheader), while you use it everywhere. The less usage we have in general the less maintenance we need, so I'd go with my solution :)I indeed forgot about
{{.WebAddress}}, it is an easy fix and I will do. As for the link in the preview page that's strange: that's the reason why I added the param at all, to be able to build the url, I will check again what I missed and fixThe navigation issue was a deliberate choice for the link to
{{.Hostname}}, since it would be the correct one, but I missed thehomelink and it can be solved with a relative url as well (having, as for the rest, two different versions of the included file: one for the download page and one for the index - this may be refactored back to a single file with some light logic in the template)as for the last question: yes, I became maintainer of the project on July 2018 ca.
@lucernae commented on GitHub:
I did some quick testing on my part:
Let's say, I deployed on
http://domain.org/transferusing a combination of haproxy docker container and transfer.sh (go binary).docker-compose.yml:
haproxy.cfg:
I test using http mode for now. Because there are still some issues.
The last section of backend with regirep line is basically me trying to remove
/transferproxy-path. Because it turns out, internally, transfer.sh is serving the index page without the proxy-path (directly after domain name).The domain name I used here: transfer.test is actually resolved to my computer ipaddress
transfer.sh run config:
What I test:
http://domain.org/transfer/xxxxx/somefile.txt{{.Url}}var was not prepended bys.proxyPathprefix inpreviewHandler.proxy-pathprepended on the url. If user read this sample and try to upload from command line, it will not work. I suggest, maybe you could changeresolveWebAddressto include proxy-path? So that every{{.webAddress}}on the index page will contain this (I'm not sure where else the variable get used, so it may affect other things).homepagelink leads to a broken url, because it is linked to the root url/. Similar with above problem, maybe it can be fixed by linking it towebAddressinstead.I think that's all for now.
I mentioned that I ended up doing some modification on my own fork, but not too confident with my code. If you're interested with it, you can check:
https://github.com/kartoza/transfer.sh/tree/add_baseurl
and
https://github.com/kartoza/transfer.sh-web/tree/add_baseurl
I ended up with a slightly different approach.
In that branch, I tried to make transfer.sh serve everything from
web-base-url(in your branch, you name itproxy-path). If I run this go binary directly the index page is located inhttp://domain.org/transferwithout having to modify the url in haproxy using regirep.It might not be the best way to do this, but at least it might give you an idea of what I'm trying to do :)
@lucernae commented on GitHub:
@aspacca
I was also going for relative URL first because it makes less change, but stumbled upon that download link. But I don't mind with any solutions, less change is better! :). I can accomodate easily with haproxy to modify the target URL.
Thanks for the help. Feel free to ping me again to test the update :).
@lucernae commented on GitHub:
Thanks @aspacca I will test that tomorrow.
@paolafrancesca commented on GitHub:
@lucernae any feedback?
@paolafrancesca commented on GitHub:
@lucernae I should have fixed everything you reported in the branch for the issue
also handling proxy path in tar/gz/zip handlers