Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WAZO-1760 add reverse proxy #29

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions debian/wazo-phoned.dirs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
etc/wazo-phoned/conf.d
etc/nginx/locations/http-enabled
etc/nginx/locations/https-enabled
8 changes: 8 additions & 0 deletions debian/wazo-phoned.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e

LOG_FILENAME='/var/log/wazo-phoned.log'
DAEMONNAME='wazo-phoned'

case "$1" in
configure)
Expand All @@ -28,6 +29,13 @@ case "$1" in
fi
# End of move files from wazo-dird-phoned

if dpkg --compare-versions "${previous_version}" lt '20.07'; then
ln -sf /etc/nginx/locations/https-available/$DAEMONNAME \
/etc/nginx/locations/https-enabled/$DAEMONNAME
ln -sf /etc/nginx/locations/http-available/$DAEMONNAME \
/etc/nginx/locations/http-enabled/$DAEMONNAME
fi

if [ ! -e "$LOG_FILENAME" ]; then
touch "$LOG_FILENAME"
fi
Expand Down
7 changes: 7 additions & 0 deletions etc/nginx/locations/http-available/wazo-phoned
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
location ^~ /api/phoned/ {
proxy_pass http://127.0.0.1:9498/;

proxy_set_header Host $http_host;
proxy_set_header X-Script-Name /api/phoned;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
7 changes: 7 additions & 0 deletions etc/nginx/locations/https-available/wazo-phoned
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
location ^~ /api/phoned/ {
proxy_pass https://127.0.0.1:9499/;

proxy_set_header Host $http_host;
proxy_set_header X-Script-Name /api/phoned;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
6 changes: 5 additions & 1 deletion wazo_phoned/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
from flask_babel import Babel
from flask_cors import CORS
from pkg_resources import iter_entry_points, resource_filename, resource_isdir
from werkzeug.contrib.fixers import ProxyFix
from xivo import http_helpers
from xivo.http_helpers import ReverseProxied

VERSION = 0.1
BABEL_DEFAULT_LOCALE = 'en'
Expand Down Expand Up @@ -83,7 +85,9 @@ def run(self):
http_config = self.config['http']
https_config = self.config['https']

wsgi_app = wsgi.WSGIPathInfoDispatcher({'/': self.app})
wsgi_app = ReverseProxied(
ProxyFix(wsgi.WSGIPathInfoDispatcher({'/': self.app}))
)
cherrypy.server.unsubscribe()
cherrypy.config.update({'environment': 'production'})

Expand Down