0

tell me please how to properly configure the web config to run asgi on the iis server?

so, now i have next web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    
    <handlers>
      <clear />
      <remove name="Python-FastCGI" />
      <remove name="Python27_via_FastCGI" />
      <remove name="Python34_via_FastCGI" />
      <add name="Python FastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="c:\users\administrator\appdata\local\programs\python\python37-32\python.exe|c:\users\administrator\appdata\local\programs\python\python37-32\lib\site-packages\wfastcgi.py" resourceType="Unspecified" />
    </handlers>
        <directoryBrowse enabled="false" />
        <httpProtocol>
            <customHeaders>
                <add name="Expires" value="1" />
            </customHeaders>
        </httpProtocol>
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
        </staticContent>
  </system.webServer>
  <appSettings>
    <add key="WSGI_HANDLER" value="django_site.wsgi.application" />
    <add key="PYTHONPATH" value="C:\Hosted\django_site" />    
    <add key="DJANGO_SETTINGS_MODULE" value="django_site.settings" />
  </appSettings>
</configuration>

but now, i'm adding the channels to the project and my app can running only from commandline in next syntax: > py -m daphne django_site.asgi:application -b abc.xyz and all works fine but without HTTPS supporting.

  1. how to properly configure the webconfig so that the site can be launched from the iis with asgi supporting?

  2. if first answer on question is not realistic, then how to run my application via command promt with HTTPS:// supporting (like, https://abc.xyz)?

I experimented with webconfig as soon as I could. Added letencrypt's certificate for the domain. But it is impossible to confuse the secure domain protocol.

P.S. now i'm try to configure my web.config

<configuration>
    <system.webServer>
        <handlers accessPolicy="Read, Execute, Script">
            <add 
              name="httpplatformhandler" 
              path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
        </handlers>
            <httpPlatform 
              processPath="C:\Project\myApp\Scripts\python.exe" 
              arguments="-m daphne myApp.asgi:application -b abc.xyz" 
              startupTimeLimit="10" 
              startupRetryCount="10" 
              stdoutLogEnabled="true" 
              stdoutLogFile=".\logs\">
            <environmentVariables>
                <environmentVariable name="myApp" value="bar" />
            </environmentVariables>
        </httpPlatform>
    </system.webServer>
</configuration>

and iis generate a lot of files in log folder with next contents:

HTTP/2 support enabled
Configuring endpoint tcp:port=8000:interface=abc.xyz
Listening on TCP address xxx.xxx.xxx.xxx:8000

i want also to remove port (:8000), but i can't do it.

  • To host a Python web app on IIS, you should use HttpPlatformHandler, https://halfblood.pro/running-flask-web-apps-on-iis-with-httpplatformhandler/ – Lex Li Jul 07 '23 at 20:18
  • As Lex Li said, wfastcgi has been deprecated, so this is no longer the correct way to host Python web applications on IIS. You can use HttpPlatformHanlder to host Django web applications. – YurongDai Jul 10 '23 at 09:36
  • @YurongDai i reconfigure web.config but it still doesn't start properly – Сергей Немец Aug 01 '23 at 20:55
  • Did you get any error pages? If so, please provide detailed error information. Also, you can use FRT to track errors, which will generate detailed log files to help you identify problems. https://learn.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis – YurongDai Aug 02 '23 at 06:23

0 Answers0