Mercurial > libervia-web
changeset 881:6bdee34fa2f4
server: added base_url_ext option to handle different external URLs (e.g.: if there is a proxy)
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 09 Mar 2016 18:38:52 +0100 |
parents | ccbad50e1426 |
children | d3d2b97aa12c |
files | src/server/blog.py src/server/server.py src/twisted/plugins/libervia_server.py |
diffstat | 3 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/server/blog.py Wed Mar 09 17:56:19 2016 +0100 +++ b/src/server/blog.py Wed Mar 09 18:38:52 2016 +0100 @@ -399,8 +399,11 @@ feed_elt = domish.Element((NS_ATOM, u'feed')) title = _(u"{user}'s blog").format(user=profile) feed_elt.addElement(u'title', content=title) - url_path = request.URLPath() - base_blog_url = u"{0.scheme}://{0.netloc}/blog/{user}".format(url_path, user=profile) + if self.host.base_url_ext is not None: + base_blog_url = u"{}blog/{user}".format(self.host.base_url_ext, user=profile) + else: + url_path = request.URLPath() + base_blog_url = u"{0.scheme}://{0.netloc}/blog/{user}".format(url_path, user=profile) # atom link link_feed_elt = feed_elt.addElement('link')
--- a/src/server/server.py Wed Mar 09 17:56:19 2016 +0100 +++ b/src/server/server.py Wed Mar 09 18:38:52 2016 +0100 @@ -1465,6 +1465,12 @@ self.options = options self.initialised = defer.Deferred() + if self.options['base_url_ext']: + self.base_url_ext = self.options.pop('base_url_ext') + if self.base_url_ext[-1] != '/': + self.base_url_ext += '/' + else: + self.base_url_ext = None if not self.options['port_https_ext']: self.options['port_https_ext'] = self.options['port_https'] if self.options['data_dir'] == DATA_DIR_DEFAULT:
--- a/src/twisted/plugins/libervia_server.py Wed Mar 09 17:56:19 2016 +0100 +++ b/src/twisted/plugins/libervia_server.py Wed Mar 09 18:38:52 2016 +0100 @@ -109,6 +109,7 @@ ['passphrase', 'k', '', (_(u"Passphrase for the SàT profile named '%s'") % C.SERVICE_PROFILE).encode('utf-8'), str], ['data_dir', 'd', DATA_DIR_DEFAULT, _(u'Data directory for Libervia').encode('utf-8'), coerceDataDir], ['allow_registration', '', True, _(u'Allow user to register new account').encode('utf-8'), coerceBool], + ['base_url_ext', '', '', _(u'The external URL to use as base URL').encode('utf-8'), str], ] # options which are in sat.conf and on command line, see https://twistedmatrix.com/documents/current/api/twisted.python.usage.Options.html # Options which are in sat.conf only OPT_PARAMETERS_CFG = [