Flask on IIS using httpPlatformHandler with SSL and hostnames

Janusz Jasinski 6 Reputation points
2022-07-07T09:23:21.287+00:00

Hi,

I was hoping to get a solution to how to get a working fastcgi enabled Flask app to use httpPlatformHandler so when we hit https://domain.internal everything works like it did with fastcgi

To get our development environment up and running we followed https://medium.com/@dpralay07/deploy-a-python-flask-application-in-iis-server-and-run-on-machine-ip-address-ddb81df8edf3 which was great as it worked. This was using FastCGI. We can visit https://domain.internal and it works great.

As it worked well, we used it for production as we were just running with a few users. However as demand is ramping up, we want to move over to either httpPlatformHandler

However httpPlatformHandler got us nowhere as we came across errors as documented here https://serverfault.com/questions/1104949/python-flask-on-iis-httpplatform-doesnt-load-when-visiting-hostname

We have an internal domain name e.g. https://digital.internal (note the SSL) and need it to work the same way. We're on Windows Server 2019 with IIS. How do we get from a work fastcgi app to one that uses

Current Site Bindings

LPQ2E.png

Current web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="Python FastCGI" path="" verb="" modules="FastCgiModule" scriptProcessor="C:\Python310\python.exe|C:\Python310\lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
</handlers>
</system.webServer>
<appSettings>
<add key="WSGI_HANDLER" value="wsgi.app" />
<add key="PYTHONPATH" value="E:\apps\prod" />
<add accessType="Allow" users="*" />
</appSettings>
</configuration>

Current wsgi.py

from digital import init_app

app = init_app()

if name == "main":
app.run(host="0.0.0.0",threaded=True)
Are there any guides, tutorials or suggestions to take us from zero to hero on this?

Internet Information Services
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.