7

I've setup a Windows Server2016 virtual machine, and installed IIS with CGI, ISAPI, .Net, etc... My only ambition for this server is to run python scripts the old CGI way: python file requested, executes in a separate new process, done.

I added a script mapping as suggested in a range of tutorials. I made sure to setup ISAPI filters and CGI restrictions accordingly. I still can't seem to solve the 404.2 I am getting. Clearly, the mapping is found, the test.py file exists, and I've opened the file system to "everyone" in "full control" to be sure that it is not the issue.

In ISAPI and CGI restrictions, I've tried different formats: with and without %s %s, with and without quotes, etc...

I've tried using that python.exe command on my scripts locally, it runs fine. Something is up with IIS and can't figure it out.

Browsing the root folder from the web browser works and lists .py files successfully.

Error while browsing from localhost Error while browsing from localhost

Script mapping on custom site Script mapping on custom site

Web config for the custom site, showing the python script mapping

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers accessPolicy="Read, Execute, Script">
            <add name="Python" path="*.py" verb="*" modules="CgiModule" scriptProcessor="C:\Anaconda3\python.exe %s %s" resourceType="Either" requireAccess="Script" />
        </handlers>
        <directoryBrowse enabled="true" />
    </system.webServer>
</configuration>

ISAPI settings at site level ISAPI settings at site level

ISAPI and CGI restrictions settings at server level ISAPI and CGI restrictions settings at server level

BuZz
  • 16,318
  • 31
  • 86
  • 141
  • 2
    check that your site and python folder has iis_iusrs and iusr full permission. and directory browsing is enabled. – Jalpa Panchal May 27 '19 at 09:13
  • thanks, check, check, and check :) – BuZz May 27 '19 at 11:14
  • is your issue is resolved? – Jalpa Panchal May 28 '19 at 01:13
  • no, it is not . – BuZz May 28 '19 at 06:57
  • could you share your python folder and what error you get after changes? – Jalpa Panchal May 28 '19 at 07:04
  • thanks, sharing to "everyone" with "full control" did not change the HTTP error. I was able to retrieve the contents of the file through file:// but through http://, still 404.2 – BuZz May 30 '19 at 07:16
  • try to assign iis_iusrs and iusr full permission to python site folder and puthon.exe root folder. – Jalpa Panchal May 30 '19 at 07:27
  • 1
    Are we certain the bitness of the AppPool and the Python processor are the same? You might also grab a copy of ProcMon and let it fire while the request is processing and see if there are any spurious/unexpected ACCESS DENIED failures when firing the processor or accessing the files. Such an error might get misinterpreted upstream as an inability to find or access the extension, with IIS assuming it must be because of CGI restrictions and returning a 404.2 – David W May 31 '19 at 16:40
  • 1
    Also, have you verified within "Handler Mappings" that the CgiModule handler is not expressly disabled? – David W May 31 '19 at 19:30
  • 1
    Can you execute the python scripts, if you create an application (rigth click on the website in IIS -> Add Application...) and configure it to execute python scripts ("Physical Path" must be the folder containing the python scripts)? Make sure to have a handler mapping with a script map (Click on the IIS Application you created -> Handler Mappings -> Add Script Map...) which is configured for python scripts (Enter the request path and executable as in the handler you already set up). – Marvin Klar Jun 03 '19 at 07:15
  • David W, can you extrapolate and make up an answer ? I'm not following everything you say and you might be on to something. – BuZz Jun 03 '19 at 11:27

0 Answers0