I have a site defined for my IIS and I have a web.config defined at site level, and my application runs fine if I also define my fastcgi handler at this level.
But I need to make this application available to many different user groups, so I define them as separate applications under the site each with a different code and each running under a separate user and python environment.
For this reason, I need to define my fastcgi handler at the application level.
When I define the fastcgi handler in my web.config at the application level, I just get a blank screen. I have been struggling with this for a long time, I really do not know why it doesn't work at application level.
I think that it is a problem with the routing, but I don't know what I need to modify to fix it.
My web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="py4webHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\Python\Miniconda3\envs\py4web2\python.exe|D:\Data\py4web\wfastcgi.py" resourceType="Unspecified" requireAccess="Execute" />
</handlers>
</system.webServer>
<appSettings>
<add key="PYTHONPATH" value="D:\Data\py4web" />
<add key="WSGI_HANDLER" value="app.application" />
<add key="WSGI_LOG" value="D:\Data\py4web\wfastcgi.log" />
</appSettings>
<system.web>
<sessionState timeout="60"></sessionState>
</system.web>
</configuration>
My wsgi handler app:
import os
from py4web.core import wsgi
# BEGIN CONFIGURATION
PASSWORD_FILENAME = 'password.txt'
DASHBOARD_MODE = 'full' # or 'demo' or 'none'
APPS_FOLDER = 'D:/Data/py4web/apps'
password_file = os.path.abspath(os.path.join(os.path.dirname(__file__), PASSWORD_FILENAME))
application = wsgi(password_file=password_file, dashboard_mode=DASHBOARD_MODE, apps_folder=APPS_FOLDER)
Debugging I added to wfastcgi.py When I define my handler at application level (doesn't work):
'wsgi.path_info': b'/py4web/'
'PATH_INFO': '/py4web/'
'PATH_TRANSLATED': 'D:\\Data\\py4web\\'
'wsgi.query_string': b''
'QUERY_STRING': ''
'REQUEST_METHOD': 'GET'
'REQUEST_URI': '/py4web/'
'SCRIPT_FILENAME': 'D:\\Data\\py4web\\'
When I define my handler at site level (works):
'wsgi.path_info': b'/'
'PATH_INFO': '/'
'PATH_TRANSLATED': 'C:\\inetpub\\wwwroot\\py4web'
'wsgi.query_string': b''
'QUERY_STRING': ''
'REQUEST_METHOD': 'GET'
'REQUEST_URI': '/'
'SCRIPT_FILENAME': 'C:\\inetpub\\wwwroot\\py4web'
I tried many different solutions but up until now the only solution that works is defining the handler in the c:\inetpub\wwwroot\mysite1\web.config
I saw this post: Running Flask via FastCGI in IIS at application level instead of website leve
And it looks similar to the issue that I am facing but I am not sure where I would need to modify the routing for the virtual directory. Help would be appreciated as I have already spent many hours on this.