Commit 1f77e1f8 authored by Riccardo Padovani's avatar Riccardo Padovani

Merge branch 'master' into scopriUbuntu

parents ba4484a6 1f3db333
...@@ -106,17 +106,19 @@ def clean(): ...@@ -106,17 +106,19 @@ def clean():
@invoke.task @invoke.task
def assets(watch=False): def assets(watch=False):
"""Build the assets""" """Build the assets"""
node_bin = "%s/node_modules/.bin" % BASE
# Be sure to have all the dependencies installed # Be sure to have all the dependencies installed
if not os.path.exists("%s/node_modules" % BASE): if not os.path.exists(node_bin):
invoke.run("npm install", pty=True) invoke.run("npm install", pty=True)
if watch: if watch:
try: try:
invoke.run("gulp watch", pty=True) invoke.run("%s/gulp watch" % node_bin, pty=True)
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
else: else:
invoke.run("gulp", pty=True) invoke.run("%s/gulp" % node_bin, pty=True)
@invoke.task(pre=[assets]) @invoke.task(pre=[assets])
......
...@@ -39,6 +39,7 @@ def cli(): ...@@ -39,6 +39,7 @@ def cli():
def run(cache, gunicorn_config, port, public, workers, debug): def run(cache, gunicorn_config, port, public, workers, debug):
# Create the application instance # Create the application instance
app = uitwww.create_app(cache) app = uitwww.create_app(cache)
app.wsgi_app = utils.ReverseProxied(app.wsgi_app)
host = "127.0.0.1" host = "127.0.0.1"
if public: if public:
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<nav role="navigation" class="nav-primary nav-right" id="nav"> <nav role="navigation" class="nav-primary nav-right" id="nav">
<span id="main-navigation-link"><a href="#main-navigation">Jump to site nav</a></span> <span id="main-navigation-link"><a href="#main-navigation">Jump to site nav</a></span>
<div class="logo"> <div class="logo">
<a href="/">ubuntu-it</a> <a href="{{ url_for("pages.index") }}">ubuntu-it</a>
{# Used <ol> so it won't be styled #} {# Used <ol> so it won't be styled #}
<div class="website-selector"> <div class="website-selector">
<ol> <ol>
......
...@@ -49,3 +49,39 @@ class GunicornInstance(baseapp.BaseApplication): ...@@ -49,3 +49,39 @@ class GunicornInstance(baseapp.BaseApplication):
if self.app is None: if self.app is None:
raise RuntimeError("Application object not set") raise RuntimeError("Application object not set")
return self.app return self.app
class ReverseProxied:
'''Wrap the application in this middleware and configure the
front-end server to add these headers, to let you quietly bind
this to a URL other than / and to an HTTP scheme that is
different than what is used locally.
Created by Peter Hansen and released in the public domain.
In nginx:
location /myprefix {
proxy_pass http://192.168.0.1:5001;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name /myprefix;
}
:param app: the WSGI application
'''
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
script_name = environ.get('HTTP_X_SCRIPT_NAME', '')
if script_name:
environ['SCRIPT_NAME'] = script_name
path_info = environ['PATH_INFO']
if path_info.startswith(script_name):
environ['PATH_INFO'] = path_info[len(script_name):]
scheme = environ.get('HTTP_X_SCHEME', '')
if scheme:
environ['wsgi.url_scheme'] = scheme
return self.app(environ, start_response)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment