Update call to proxy fix to use new method signature

Old method:

```python
ProxyFix(app, num_proxies=1)
```
https://werkzeug.palletsprojects.com/en/0.14.x/contrib/fixers/#werkzeug.contrib.fixers.ProxyFix

This uses forwarded values for `REMOTE_ADDR` and `HTTP_HOST`.

New method:
```python
ProxyFix(app, num_proxies=None, x_for=1, x_proto=0, x_host=0, x_port=0, x_prefix=0)
```
https://werkzeug.palletsprojects.com/en/0.15.x/middleware/proxy_fix/#module-werkzeug.middleware.proxy_fix

Setting `x_for=1` preserves the same behaviour as `num_proxies=1`.
Setting  `x_proto=1` and `x_host=1` will cause `REMOTE_ADDR`,
`HTTP_HOST`, `SERVER_NAME` and `SERVER_PORT` to be forwarded.

So we will be forwarding `SERVER_NAME` and `SERVER_PORT` which we
weren’t before, but we think this is OK.
This commit is contained in:
Chris Hill-Scott
2019-03-25 10:52:21 +00:00
parent 615abf21e5
commit db3cee63ba

View File

@@ -3,7 +3,7 @@ from werkzeug.middleware.proxy_fix import ProxyFix
class CustomProxyFix(object):
def __init__(self, app, forwarded_proto):
self.app = ProxyFix(app)
self.app = ProxyFix(app, x_for=1, x_proto=1, x_host=1, x_port=0, x_prefix=0)
self.forwarded_proto = forwarded_proto
def __call__(self, environ, start_response):