[#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.
This commit is contained in:
parent
ec366c840c
commit
64ac5fdf73
|
@ -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")
|
||||
|
|
|
@ -59,10 +59,8 @@ class Web(UI):
|
|||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
group.add_argument("--no-ssl", dest="ssl", action="store_false",
|
||||
help="Forces the webserver to disable ssl", default=False)
|
||||
group.add_argument("--ssl", dest="ssl", action="store_true",
|
||||
help="Forces the webserver to use ssl", default=False)
|
||||
group.add_argument("--ssl", action="store_true", help="Forces the webserver to use ssl")
|
||||
group.add_argument("--no-ssl", action="store_true", help="Forces the webserver to disable ssl")
|
||||
|
||||
@property
|
||||
def server(self):
|
||||
|
@ -97,18 +95,7 @@ class Web(UI):
|
|||
os.setuid(self.options.user)
|
||||
|
||||
from deluge.ui.web import server
|
||||
self.__server = server.DelugeWeb()
|
||||
|
||||
if self.options.base:
|
||||
self.server.base = self.options.base
|
||||
|
||||
if self.options.interface:
|
||||
self.server.interface = self.options.interface
|
||||
|
||||
if self.options.port:
|
||||
self.server.port = self.options.port
|
||||
|
||||
self.server.https = self.options.ssl
|
||||
self.__server = server.DelugeWeb(options=self.options)
|
||||
|
||||
def run():
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue