roemhildtg roemhildtg - 1 month ago 15
Python Question

How to configure flask session behind iis reverse proxy (wfastcgi)?

I'm configuring my flask app to run under iis with a reverse proxy. Basically my setup is like this:

external.domain.com:8000 ->
Reverse Proxy IIS ->
interal.network.net ->
iis (wfastcgi/flask)


The app's urls and content is loading correctly, but anything that deals with a session is not working:


  • Message flashing - no messages are flashed

  • Login cookies - not able to login at all



I've configured the flask app with these relevent config variables:

SERVER_NAME = 'internal.network.net'
SESSION_COOKIE_DOMAIN = 'external.domain.com'


I have an IIS rewrite rule set up on the external server:

Pattern: (.*)
Rewrite URL: http://internal.network.net/{R:1}


Is there anything else I need to configure to get sessions working correctly?

Answer

Not sure if this is the correct way of doing things but apparently excluding the properties SERVER_NAME and SESSION_COOKIE_DOMAIN actually fixes the issue.

Hope this helps someone.

Comments