from werkzeug.middleware.proxy_fix import ProxyFix


class CustomProxyFix(object):
    def __init__(self, app, forwarded_proto):
        self.app = ProxyFix(app)
        self.forwarded_proto = forwarded_proto

    def __call__(self, environ, start_response):
        environ.update({
            "HTTP_X_FORWARDED_PROTO": self.forwarded_proto
        })
        return self.app(environ, start_response)


def init_app(app):
    app.wsgi_app = CustomProxyFix(app.wsgi_app, app.config.get('HTTP_PROTOCOL', 'http'))

from werkzeug.middleware.proxy_fix import ProxyFix


class CustomProxyFix(object):
    def __init__(self, app, forwarded_proto):
        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):
        environ.update({
            "HTTP_X_FORWARDED_PROTO": self.forwarded_proto
        })
        return self.app(environ, start_response)


def init_app(app):
    app.wsgi_app = CustomProxyFix(app.wsgi_app, app.config.get('HTTP_PROTOCOL', 'http'))

Update call to proxy fix to use new method signature
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.

  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):
          environ.update({
              "HTTP_X_FORWARDED_PROTO": self.forwarded_proto
          })
          return self.app(environ, start_response)
  
  
  def init_app(app):
      app.wsgi_app = CustomProxyFix(app.wsgi_app, app.config.get('HTTP_PROTOCOL', 'http'))
  
Update call to proxy fix to use new method signature
## Code Before:
from werkzeug.middleware.proxy_fix import ProxyFix


class CustomProxyFix(object):
    def __init__(self, app, forwarded_proto):
        self.app = ProxyFix(app)
        self.forwarded_proto = forwarded_proto

    def __call__(self, environ, start_response):
        environ.update({
            "HTTP_X_FORWARDED_PROTO": self.forwarded_proto
        })
        return self.app(environ, start_response)


def init_app(app):
    app.wsgi_app = CustomProxyFix(app.wsgi_app, app.config.get('HTTP_PROTOCOL', 'http'))

## Instruction:
Update call to proxy fix to use new method signature
## Code After:
from werkzeug.middleware.proxy_fix import ProxyFix


class CustomProxyFix(object):
    def __init__(self, app, forwarded_proto):
        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):
        environ.update({
            "HTTP_X_FORWARDED_PROTO": self.forwarded_proto
        })
        return self.app(environ, start_response)


def init_app(app):
    app.wsgi_app = CustomProxyFix(app.wsgi_app, app.config.get('HTTP_PROTOCOL', 'http'))
