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

时间:2016-10-19 13:35:27

标签: python session iis flask reverse-proxy

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?

1 个答案:

答案 0 :(得分:0)

不确定这是否是正确的做事方式,但显然排除属性SERVER_NAMESESSION_COOKIE_DOMAIN实际上解决了问题。

希望这有助于某人。