diff --git a/src/calibre/gui2/preferences/server.py b/src/calibre/gui2/preferences/server.py index 16f2eb7316..2a62fe555f 100644 --- a/src/calibre/gui2/preferences/server.py +++ b/src/calibre/gui2/preferences/server.py @@ -36,6 +36,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): r('max_cover', self.proxy) r('max_opds_items', self.proxy) r('max_opds_ungrouped_items', self.proxy) + r('url_prefix', self.proxy) self.show_server_password.stateChanged[int].connect( lambda s: self.opt_password.setEchoMode( @@ -100,7 +101,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): self.stopping_msg.accept() def test_server(self): - open_url(QUrl('http://127.0.0.1:'+str(self.opt_port.value()))) + prefix = unicode(self.opt_url_prefix.text()).strip() + open_url(QUrl('http://127.0.0.1:'+str(self.opt_port.value())+prefix)) def view_server_logs(self): from calibre.library.server import log_access_file, log_error_file diff --git a/src/calibre/gui2/preferences/server.ui b/src/calibre/gui2/preferences/server.ui index 4c8691500c..64af212265 100644 --- a/src/calibre/gui2/preferences/server.ui +++ b/src/calibre/gui2/preferences/server.ui @@ -16,36 +16,6 @@ - - - - Server &port: - - - opt_port - - - - - - - 65535 - - - 8080 - - - - - - - &Username: - - - opt_username - - - @@ -91,6 +61,36 @@ Leave this blank if you intend to use the server with an + + + + Server &port: + + + opt_port + + + + + + + 65535 + + + 8080 + + + + + + + &Username: + + + opt_username + + + @@ -181,6 +181,23 @@ Leave this blank if you intend to use the server with an + + + + &URL Prefix: + + + opt_url_prefix + + + + + + + A prefix that is applied to all URLs in the content server. Useful only if you plan to put the server behind another server like Apache, with a reverse proxy. + + + diff --git a/src/calibre/library/server/base.py b/src/calibre/library/server/base.py index b5cf2e5ef3..096326917c 100644 --- a/src/calibre/library/server/base.py +++ b/src/calibre/library/server/base.py @@ -122,6 +122,8 @@ class LibraryServer(ContentServer, MobileServer, XMLServer, OPDSServer, Cache, path = P('content_server') self.build_time = fromtimestamp(os.stat(path).st_mtime) self.default_cover = open(P('content_server/default_cover.jpg'), 'rb').read() + if not opts.url_prefix: + opts.url_prefix = '' cherrypy.engine.bonjour.port = opts.port cherrypy.engine.bonjour.prefix = opts.url_prefix