A little late to the party, but here (Flask v1) is what the documentation says about ProxyFix.
Documentation for v2
To paraphrase: Deploying your server using gunicorn behind an HTTP proxy you will need to rewrite some of the headers so that the application can work. And Werkzeug ships with a fixer that will solve some of the common setups.
from werkzeug.middleware.proxy_fix import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
Answer from Thomas Gak-Deluen on Stack OverflowA little late to the party, but here (Flask v1) is what the documentation says about ProxyFix.
Documentation for v2
To paraphrase: Deploying your server using gunicorn behind an HTTP proxy you will need to rewrite some of the headers so that the application can work. And Werkzeug ships with a fixer that will solve some of the common setups.
from werkzeug.middleware.proxy_fix import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
You need to show the code that defines your Flask application "app".
Where is "app" defined? Are you importing it from another file?
Here is my attempt to reproduce the issue:
$ cat myproject.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return "ok"
$ bin/gunicorn -w 4 -b 127.0.0.1:4000 myproject:app &
[1] 27435
2014-03-04 12:18:36 [27435] [INFO] Starting gunicorn 18.0
2014-03-04 12:18:36 [27435] [INFO] Listening at: http://127.0.0.1:4000 (27435)
2014-03-04 12:18:36 [27435] [INFO] Using worker: sync
2014-03-04 12:18:36 [27441] [INFO] Booting worker with pid: 27441
2014-03-04 12:18:36 [27442] [INFO] Booting worker with pid: 27442
2014-03-04 12:18:36 [27445] [INFO] Booting worker with pid: 27445
2014-03-04 12:18:36 [27448] [INFO] Booting worker with pid: 27448
$ curl http://127.0.0.1:4000/
ok
As you can see it works fine. You definitely don't need ProxyFix in this case.
» pip install flask-reverse-proxy-fix
Werkzeug 1.0.0 has removed deprecated code, including all of werkzeug.contrib. You should use alternative libraries for new projects. werkzeug.contrib.session was extracted to secure-cookie.
If an existing project you're using needs something from contrib, you'll need to downgrade to Werkzeug<1:
pip3 install Werkzeug<1
You will need to downgrade werkzeug version from 1.0.0 to 0.16.0
This solved the problem for me.
Just run the following commands in your project:
python3 -m pip uninstall werkzeug
and then
python3 -m pip install werkzeug==0.16.0