summaryrefslogtreecommitdiffstats
path: root/deluge/ui/web/server.py
diff options
context:
space:
mode:
authorbendikro <bro.devel+deluge@gmail.com>2016-04-22 20:53:13 +0200
committerCalum Lind <calumlind+deluge@gmail.com>2016-04-22 23:04:19 +0100
commit64ac5fdf73f2fecc84e07615cd6fcdc0f7ffde19 (patch)
tree0ddd3cff3ebec1234c2c03061c0680a96be9ee3d /deluge/ui/web/server.py
parentec366c840c14ec6c983950ee164a401dd260647a (diff)
downloaddeluge-64ac5fdf73f2fecc84e07615cd6fcdc0f7ffde19.tar.gz
deluge-64ac5fdf73f2fecc84e07615cd6fcdc0f7ffde19.tar.bz2
deluge-64ac5fdf73f2fecc84e07615cd6fcdc0f7ffde19.zip
[#2677] [Web] With --base option set, serve locally on new base path
When specifying the --base option to work with reverse proxy the WebUI is no longer accessible locally since it listens on the server root, but serves on the path specified to work for the reverse proxy. Change this to also handle local requests to the base path such that the WebUI will be available both for the reverse proxy as well as locally on the interface/port which the twisted sever listens on.
Diffstat (limited to 'deluge/ui/web/server.py')
-rw-r--r--deluge/ui/web/server.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py
index 41671f067..591eeec9b 100644
--- a/deluge/ui/web/server.py
+++ b/deluge/ui/web/server.py
@@ -530,18 +530,33 @@ class TopLevel(resource.Resource):
class DelugeWeb(component.Component):
- def __init__(self):
+ def __init__(self, options=None):
super(DelugeWeb, self).__init__("DelugeWeb")
self.config = configmanager.ConfigManager("web.conf", CONFIG_DEFAULTS)
self.socket = None
self.top_level = TopLevel()
- self.site = server.Site(self.top_level)
+
self.interface = self.config["interface"]
self.port = self.config["port"]
self.https = self.config["https"]
self.pkey = self.config["pkey"]
self.cert = self.config["cert"]
self.base = self.config["base"]
+
+ if options:
+ self.interface = options.interface if options.interface else self.interface
+ self.port = options.port if options.port else self.port
+ self.base = options.base if options.base else self.base
+ if options.ssl:
+ self.https = True
+ elif options.no_ssl:
+ self.https = False
+
+ if self.base != "/":
+ # Strip away slashes and serve on the base path as well as root path
+ self.top_level.putChild(self.base.strip('/'), self.top_level)
+
+ self.site = server.Site(self.top_level)
self.web_api = WebApi()
self.auth = Auth(self.config)
self.standalone = True
@@ -596,7 +611,7 @@ class DelugeWeb(component.Component):
def start_normal(self):
self.socket = reactor.listenTCP(self.port, self.site, interface=self.interface)
- log.info("Serving at http://%s:%s", self.interface, self.port)
+ log.info("Serving at http://%s:%s%s", self.interface, self.port, self.base)
def start_ssl(self):
check_ssl_keys()
@@ -610,7 +625,7 @@ class DelugeWeb(component.Component):
options.getContext().set_options(SSL.OP_NO_SSLv2 | SSL.OP_NO_SSLv3)
self.socket = reactor.listenSSL(self.port, self.site, options, interface=self.interface)
- log.info("Serving at https://%s:%s", self.interface, self.port)
+ log.info("Serving at https://%s:%s%s", self.interface, self.port, self.base)
def stop(self):
log.info("Shutting down webserver")