1

I have a django application deployed on an AWS IIS server. Static fils are served just fine via 'runserver', but not via the IIS server. I have done everything right but it doesn't work. i even tried adding a static folder virtual directory but it didnt work. this is my webconfig:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <appSettings>
    <!-- Required settings -->
    <add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
    <!-- Your django path -->
    <add key="PYTHONPATH" value="C:\myvenv2\NutMIS" /> 
    <!-- Your djangoname.settings -->
    <add key="DJANGO_SETTINGS_MODULE" value="NutMIS.settings" />
  </appSettings>
  <system.webServer>
<handlers>
      <!-- Remove duplicate entries -->
      <remove name="NutMIS" />
      <remove name="StaticFiles" />
      <remove name="StaticFile" />
      
      <!-- Add handler for StaticFiles -->
      <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" resourceType="Unspecified" requireAccess="Read" />
      
      <!-- Add your custom NutMIS handler -->
      <add name="NutMIS" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Users\Administrator\AppData\Local\Programs\Python\Python311\python.exe|C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
    </handlers>
<staticContent>
            <mimeMap fileExtension=".*" mimeType="application/octet-stream" />
        </staticContent>
  </system.webServer>
</configuration>

this is my settings:

STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / "static"

The static files feature is installed in my IIS. My 'static' folder is placed in the app folder and it works just fine via runserver but not via the public IP over IIS. Please i need help with this.

i also tried adding this web.config to to my static file folder but it didnt work:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <!-- 
      This removes Helicon Zoo handler and makes IIS processing static files.
      -->
      <remove name="django.project#x64" />
      <remove name="django.project#x86" />
    </handlers>
  </system.webServer>
</configuration>

1 Answer 1

0

For future readers, wfastcgi has been deprecated and known to be problematic.

If you revert all changes related to FastCGI and start cleanly with HttpPlatformHandler, you will see how smooth the experience is,

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
        </handlers>
        <httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\python.log" startupTimeLimit="20" processPath="C:\Users\<user name>\AppData\Local\Programs\Python\Python310\python.exe" arguments=".\mysite\manage.py runserver %HTTP_PLATFORM_PORT%">
        </httpPlatform>
    </system.webServer>
</configuration>

Python/Django still takes care of everything including static files, and IIS/HttpPlatformHandler just passes requests on.

More details can be found from my blog post.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .