nginx as reverse proxy for the config-page


Recommended Posts

Hi,

i just started using btsync and already deployed it on several systems including some "servers".

As the btsync config page has not authorization mechanism, i have thought i could use the already installed nginx webserver for that and use it as an reverse proxy:

/etc/nginx/sites-enabled/default:

...

location ~ ^/btsync($|./*) {

proxy_pass http://127.0.0.1:8888;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

...

Almost the same lines work for other services, but not for btsync, i only get:

"invalid request"

Any ideas?

Link to post
Share on other sites

This piece of code works like a charm:

 location /btsync/ {
rewrite ^/btsync/gui(.*) /btsync$1 last;
proxy_pass http://127.0.0.1:8888/gui/;
proxy_redirect /gui/ /btsync/;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}

(LoL! I was writing a long post criticizing GUI's JS when I suddenly noticed that I wrote the "rewrite" statement with "break" instead of "last".)

Link to post
Share on other sites
  • 1 month later...

Yeah! I just noticed that.

If any btsync developer is reading this... I'd like to ask why there's a Javascript redirection at the root.

Doing this way forces me to have another nginx directive to control what is going to /gui/ because nginx only intercepts HTTP redirects...

For now, this additional directive helps out, but we will lose the pretty /btsync URL... (we are still able to access /btsync but there will be a redirection to /gui)

location /gui/ {
proxy_pass http://127.0.0.1:8888/gui/;
}

Link to post
Share on other sites
  • 4 weeks later...
  • 8 months later...
  • 3 months later...
  • 2 weeks later...
  • 1 year later...

Here's what I did for apache2:

- First I enabled the needed apache2 mods

sudo a2enmod proxy_html
sudo a2enmod xml2enc

- Next I put this in the file /etc/apache2/sites-available/default-ssl.conf (Replace [PORT] with the btsync port)

ProxyPass /btsync http://127.0.0.1:[PORT]
ProxyPassReverse /btsync http://127.0.0.1:[PORT]
ProxyHTMLInterp On http://127.0.0.1:[PORT] /btsync
Redirect permanent /gui /btsync/gui

Working for me on apache2 now

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.