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

Specify a web root for the WebUi #1106

Closed
randomessence opened this Issue Dec 9, 2014 · 16 comments

Comments

Projects
None yet
7 participants
@randomessence
Copy link

randomessence commented Dec 9, 2014

Is there a way to specify the web root in the WebUi?

If not could this be added?

The specific issue is a proxypass/webserver/reverse proxy configuration in a subdirectory where i need to force a webroot so as to have a working proxypass.

@calmh

This comment has been minimized.

Copy link
Member

calmh commented Dec 9, 2014

You don't need to change the web root to put a proxy in front of syncthing. All URL:s served are relative.

@randomessence

This comment has been minimized.

Copy link
Author

randomessence commented Dec 9, 2014

I need to specify it to work with the particular setup i an working with.

@calmh

This comment has been minimized.

Copy link
Member

calmh commented Dec 9, 2014

Perhaps if you can explain your use case then? Lots of people have the GUI running behind nginx or apache already.

@uok

This comment has been minimized.

Copy link
Contributor

uok commented Dec 10, 2014

For apache there is a thread in the forum

@randomessence

This comment has been minimized.

Copy link
Author

randomessence commented Dec 10, 2014

edit: this applies to apache or nginx which must still go through a separate nginx reverse proxy handling https.

The specific example is where syncthing is behind a reverse proxy that customizes the relative portion of the URL with regards to https urls for a multi user environment. Not necessarily a common setup but pretty standard non the less.

Syncthing cannot detect this inserted/customized part of the URL so the only option is to force the web root in order to work with the proxypass.

The point is having a web root allows a user to force/override the web root in certain circumstances. Which i am sure is something that could easily occur in other non default setups.

@jpjp

This comment has been minimized.

Copy link
Contributor

jpjp commented Dec 10, 2014

Can you show us the 404 error and the link that gives the 404?

@calmh

This comment has been minimized.

Copy link
Member

calmh commented Dec 12, 2014

I'm still not clear on what the actual problem is here. Perhaps if you explain what kind of URL rewriting you are doing, and how being able to set the base URL on syncthing would help?

@randomessence

This comment has been minimized.

Copy link
Author

randomessence commented Dec 14, 2014

I got this working. I probably made the mistake of assuming some stuff after dealing with btsync and whatever that does with the WebUi.

The proxypass was pretty standard and worked so far for the WebUi. You can consider this closed.

@dangmai

This comment has been minimized.

Copy link

dangmai commented Oct 9, 2016

I know this ticket has been closed for awhile now, but I'm still hoping that it can be reconsidered.

My use case is that I'm using Caddy to reverse proxy a subdirectory to Syncthing (let's say http://test.com/syncthing). By default, Caddy proxies requests to http://localhost:8384/syncthing, which returns 404.

It does have an option to specify a prefix to trim before sending a request to upstream - so for example, if I specify without /syncthing, Syncthing will receive a request at http://localhost:8384 correctly. However, if I use that option, Syncthing returns all assets relative to http://test.com instead of http://test.com/syncthing. The vendor libraries will be at http://test.com/vendor/ instead of http://test.com/syncthing/vendor, which is not the correct behavior.

That issue is semi fixable if I rewrite URL based on the referrer of the request, but at that point it's really more complicated than it needs to be (and also some assets that don't have the referrer needed won't be proxied correctly). So I'm hoping that Syncthing can just add the option for a web root, which would simplify the set up considerably (at that point the default proxy would Just Work™).

Thanks a lot!

@AudriusButkevicius

This comment has been minimized.

Copy link
Member

AudriusButkevicius commented Oct 9, 2016

Technically, the reverse proxy should rewrite the URLs

@calmh

This comment has been minimized.

Copy link
Member

calmh commented Oct 10, 2016

It currently Just Works(tm) with both Nginx and Apache proxying. If it doesn't with Caddy, I think the unusual behavior is on Caddy's side. At least for me it's quite common to have lots of small services that all consider / to be their namespace, and then something in front of that that binds /foo to http://localhost:8123/, /bar to http://localhost:8124/ and so on. Syncthing fits in perfectly in such a setup.

@uok

This comment has been minimized.

Copy link
Contributor

uok commented Oct 10, 2016

or you could use http://syncthing.example.com and proxy requests to http://localhost:8384

@dangmai

This comment has been minimized.

Copy link

dangmai commented Oct 10, 2016

Argh you guys are of course right - it's a Caddy misunderstanding on my part. Trimming the prefix with without does work, however if I don't include the trailing slash (/) at the end of my URL it won't proxy to the right thing. I can either include that trailing slash manually or do a redirection automatically. Here's part of my Caddy config now that works, in case people try to search for it later:

redir /syncthing /syncthing/ 302
proxy /syncthing http://syncthing:8384/ {
  transparent
  without /syncthing
}
@randomessence

This comment has been minimized.

Copy link
Author

randomessence commented Oct 10, 2016

The reason I originally considered this issue resolved was because I used these proxypass configurations with apache and nginx respectively and it worked perfectly without needing to specify a webroot which was needed with btsync. I guess syncthing was coded better.

Note: this is for a webhost where the https url is non implemented in tradition way so it may not work as a copy and paste solution but it worked for me exactly how i needed it work work and i successfully proxypassed to a custom web sub directory.

Apache:

Include /etc/apache2/mods-available/proxy.load
Include /etc/apache2/mods-available/proxy_http.load
Include /etc/apache2/mods-available/headers.load
Include /etc/apache2/mods-available/ssl.load

ProxyRequests Off
ProxyPreserveHost On
ProxyVia On
SSLProxyEngine on

ProxyPass /syncthing http://10.0.0.1:PORT
ProxyPassReverse /syncthing http://10.0.0.1:PORT

Nginx:

location /syncthing {
    proxy_set_header        Host            $http_x_host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    # redirect for no trailing slash
    rewrite ^/syncthing$ https://$http_x_host/USERNAME/syncthing/ permanent;
    #
    rewrite /syncthing/(.*) /$1 break;
    proxy_pass http://10.0.0.1:PORT;
    proxy_redirect off;
    proxy_buffering off;
}
@letroll

This comment has been minimized.

Copy link

letroll commented Jan 14, 2017

it's not working for me ( nginx with let's encrypt cert, on archlinux)

@syncthing syncthing locked and limited conversation to collaborators Jan 14, 2017

@AudriusButkevicius

This comment has been minimized.

Copy link
Member

AudriusButkevicius commented Jan 14, 2017

Use forum for support.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.