Skip to content

IIS setup

Install Python 3.5

From https://www.python.org/downloads/ download and install the 64bits version.

IIS

Please check the following documentation: http://www.iis.net/learn/install/installing-iis-85/installing-iis-85-on-windows-server-2012-r2 in order to install IIS on Windows 2012R2.

Install the Microsoft Web Platform Installer for easy components upgrade for IIS: https://www.microsoft.com/web/downloads/platform.aspx

wfastcgi.py can be found at http://pytools.codeplex.com/wikipage?title=wfastcgi . Please dont forget to install flask on the environment you are using (e.g. Python3.5 32 or 64 bits).

Once you can do http://localhost on a browerser, to be able to run Flask & Python check: http://netdot.co/2015/03/09/flask-on-iis/ , http://developer.e-power.com.kh/publish-flask-on-iis/ & https://medium.com/@as_w/running-a-python-web-app-flask-on-windows-server-iis-using-fastcgi-and-wfastcgi-py-b49875b637f7#.5dl4j6kkr . Basically under "Application Development" install CGI role. And then follow instructions on the above articles. Just some pics about the process.

Create the site, in our case located at: \cern.ch\dfs\Services\conversion\production-test02\doconverterwww\project\doconverter setupwebsite01.png

Create the handler and add a WSGI_HANDLER variable that should point to your app.py file, e.g.: app.app (see web services help page web services. setupwebsite02.png

Under the server add following variables at FastCGI settings: setupwebsite03.png

Your web.config at your project location should be something similar to:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers accessPolicy="Read, Script">
            <remove name="CGI-exe" />
            <add name="doconverter" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Python35\python.exe|c:\Python35\Scripts\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
        </handlers>
        <tracing>
            <traceFailedRequests>
                <add path="*">
                    <traceAreas>
                        <add provider="ASP" verbosity="Verbose" />
                        <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
                        <add provider="ISAPI Extension" verbosity="Verbose" />
                        <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket" verbosity="Verbose" />
                    </traceAreas>
                    <failureDefinitions statusCodes="500" />
                </add>
            </traceFailedRequests>
        </tracing>
    </system.webServer>
    <appSettings>
         <add key="WSGI_HANDLER" value="app.app" />
         <add key="PYTHONPATH" value="\\cern.ch\dfs\Services\conversion\production-test02\doconverterwww\project\doconverter" />
    </appSettings>
</configuration>

ISS software

To debug certain issues it may be needed to setup logging. Please follow instructions at IIS logging. Some of the roles and features require software that it's not present in the openstack image. Use following path as external source: \\cern.ch\dfs\Systems\Microsoft\Windows2012 R2\en_windows_server_2012_r2_x64_dvd_2707946\sources\sxs

IIS permissions

The application pool should be run under CERN\cdsconv. To change it go to IIS manager -> Application pools -> doconverter and select 'Advanced Settings'

setupwebsite04.png

Failed traces

To how to setup please follow: https://www.iis.net/learn/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis-85

In case you want to increase the size of the trace logs please do:

https://blogs.msdn.microsoft.com/robert_mcmurray/2008/03/08/freb-log_file_max_size_truncate/

cd /d “%windir%\system32\inetsrv”
C:\Windows\System32\inetsrv>appcmd set config /section:sites -siteDefaults.traceFailedRequestsLogging.maxLogFileSizeKB:102400
Applied configuration changes to section "system.applicationHost/sites" for "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"

appcmd set config /section:sites -siteDefaults.traceFailedRequestsLogging.enabled:true
appcmd set config /section:sites -siteDefaults.traceFailedRequestsLogging.maxLogFiles:10
appcmd set config /section:sites -siteDefaults.traceFailedRequestsLogging.maxLogFileSizeKB:512

HTTPS setup

For windows server use CERNCA autoenrollment: cerncautoenrollment.png

In one or two days you should get the certificate automatically installed on the machine, using mmc.exe -> add certificate snap-in for the local computer:

localcertificate.png


Last update: October 4, 2021