0

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>

Henry
  • 1
  • 2
  • Hi @Henry, this is a configuration question, and not a coding question. As such it is more suitable at [serverfault](https://serverfault.com/). Good luck. – Uberhumus Aug 16 '23 at 10:47
  • Do you have read and access permissions for this static file? Try restarting the IIS server to see if that works, if possible, you can check error messages or related logs to narrow down the problem. And maybe you can refer to this [similar case](https://stackoverflow.com/questions/32312590/how-to-fetch-static-css-files-with-django-on-iis). – Xudong Peng Aug 17 '23 at 06:30

0 Answers0