Reputation: 51
I have a flask application running on a server (192.168.1.1:8080
) located behind a reverse proxy. Let's say, the url https://foo.bar.com/myapp
point to my flask app, i.e. to 192.168.1.1:8080
.
I am in trouble with the url_for
flask function, as it returns something like http://192.168.1.1:8080/blabla
(giving blabla
as parameter).
How to proceed so that url_for
returns https://foo.bar.com/myapp/blabla
instead ?
In fact, my application uses a CAS authentication system. So that the ticket gets validate by the CAS server, I need to provide an URL of the shape https://foo.bar.com/...
.
Any help would be appreciate.
Upvotes: 3
Views: 1582
Reputation: 51
I found a solution using ProxyFix
from werkzeug
:
from werkzeug.middleware.proxy_fix import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app, x_host=1)
Upvotes: 2