0

I have a Windows Server 2019, running IIS. I use WFASTCGI to serve my Flask apps according to a specific IP and port (for instance 151.80.60.225:5000), and my web.config file works well. However, I want to serve multiple apps on the same IP:port (151.80.60.225:5000) using /routes like that:

151.80.60.225:5000/ ==> Home
------> 151.80.60.225:5000/app1 ==> App1
------> 151.80.60.225:5000/app2 ==> App2
------> 151.80.60.225:5000/app3 ==> App3
------> 151.80.60.225:5000/app4 ==> App4

I create a pool in IIS with an apps website, hosting itself app1 website, app2 website,... IIS arbo

I have a web.config for each file and the structure is like this:

<configuration>
  <system.webServer>
    <handlers>
      <add name="Python FastCGI"
           path="*"
           verb="*"
           modules="FastCgiModule"
           scriptProcessor="c:\users\administrator\appdata\local\programs\python\python39\python.exe|c:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\wfastcgi.py"
           resourceType="Unspecified"
           requireAccess="Script" />
    </handlers>
  </system.webServer>

  <appSettings>
    <!-- Required settings -->
    <add key="WSGI_HANDLER" value="__init__.app" />
    <add key="PYTHONPATH" value="C:\apps\app1\app" />

    <!-- Optional settings -->
    <add key="WSGI_LOG" value="C:\apps\logs\app1.log" />
  </appSettings>
</configuration>

So I have a WFASTCGI web.config file for MES app (like a homepage) and WFASTCGI web.config file for each app. But when I go to 151.80.60.225:5000/app1, I have a "not found error page".

My question is: What is a good way to structure a portal like I want to do?

Thanks for your help.

Error pages (404 not found): Error page localhost

Error page with full IP

Edit on January 22:

I follow your tip, but I have still the 404 not found page.

My settings are below, anything is wrong? Not found - Settings

Furthermore, I authorize DefaultAppPool to full access to the directory, and test settings is fine.

Edit on January 23: Please find below the FailedReqLogFile with sub status code 0 and error code 404:

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
 <System>
  <Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/>
  <EventID>0</EventID>
  <Version>1</Version>
  <Level>3</Level>
  <Opcode>16</Opcode>
  <Keywords>0x100</Keywords>
  <TimeCreated SystemTime="2021-01-23T09:39:47.068Z"/>
  <Correlation ActivityID="{80000036-0000-E300-B63F-84710C7967BB}"/>
  <Execution ProcessID="11112" ThreadID="12496"/>
  <Computer>WIN-xxxxxx</Computer>
 </System>
 <EventData>
  <Data Name="ContextId">{80000036-0000-E300-B63F-84710C7967BB}</Data>
  <Data Name="ModuleName">FastCgiModule</Data>
  <Data Name="Notification">128</Data>
  <Data Name="HttpStatus">404</Data>
  <Data Name="HttpReason">NOT FOUND</Data>
  <Data Name="HttpSubStatus">0</Data>
  <Data Name="ErrorCode">0</Data>
  <Data Name="ConfigExceptionInfo"></Data>
 </EventData>
 <RenderingInfo Culture="fr-FR">
  <Opcode>MODULE_SET_RESPONSE_ERROR_STATUS</Opcode>
  <Keywords>
   <Keyword>RequestNotifications</Keyword>
  </Keywords>
  <freb:Description Data="Notification">EXECUTE_REQUEST_HANDLER</freb:Description>
  <freb:Description Data="ErrorCode">The operation completed successfully.
 (0x0)</freb:Description>
 </RenderingInfo>
 <ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
  <EventGuid>{002E91E3-E7AE-44AB-8E07-99230FFA6ADE}</EventGuid>
 </ExtendedTracingInfo>
</Event>
Fred
  • 169
  • 1
  • 3
  • 19
  • Through your description of error, I cannot get enough error message. Can you show the error page ordetailed error message and status code? By the way, it is impossible to host multiples sub python application on same application pool. Not only python, but also php, .net core application. It is best to assign each application to one application pool. – Bruce Zhang Jan 19 '21 at 08:08
  • I understand your comment. But do I need to assign one port for each app? Or can I assign one port for the portal and manage sub-routes like /app1, /app2,..., /appn for each app? The idea is to create a portal for all the tools (apps) and only navigate through URLs. I edited my post with error pages. Thanks for your help. – Fred Jan 19 '21 at 18:36
  • If you set app1,2,3 as main site, can it work? 404.0 means fille cannot be found, so I think maybe something wrong with route. The error page is belong to flask app not IIS. Request has gotten into flask app but it didnot follow the correct route. – Bruce Zhang Jan 25 '21 at 09:46
  • Yes it works when I set app1 as website. So you think the issue comes from an error in routes in Flask? Do I have to set my alias as the default route in Flask and not / route? – Fred Jan 26 '21 at 10:32
  • The very good update is that works! The only thing I can't do is to serve my static folder with images and css files. I tried this https://stackoverflow.com/questions/2061678/iis7-web-config-to-allow-only-static-file-handler-in-directory-uploads-of-webs, but still stucked. What a nighmare! – Fred Jan 27 '21 at 06:06
  • If it is a new issue, I suggest you create a new thread and describe it and your need to get help. – Bruce Zhang Jan 27 '21 at 09:07
  • I will do, huge and many thanks for your help, I really appreciate! – Fred Jan 28 '21 at 17:06
  • If interested, I posted this issue on https://stackoverflow.com/questions/65959265/flask-static-folder-not-served-on-iis. – Fred Jan 29 '21 at 17:40

1 Answers1

0

You don't need to assign one port for each app. Just assign one port for the portal.

For example, when you add site "MES", assign port 5000 to it and you can access it through localhost:5000.

Then add app1, you will see this interface. Set alias(assuming that it is "app1") and change another application pool. It is important to assign each application to one application pool. enter image description here

After adding success, you can access app1 through "localhost:5000/app1". Same operation for app2 and app3.

If it still return error 404, first check the log in IIS to get the status code and sub status code. Sub status code will provide more detailed information.

Enable fail request tracing can collect tracing about request so that you will know what caused the issue.

Bruce Zhang
  • 2,880
  • 1
  • 5
  • 11
  • I follow your indications but still the 404 page not found. I share my settings on the initial post, on section 'Edit on January 22'. – Fred Jan 22 '21 at 07:29
  • Do you access the site through http://xxxx:5000/vision_xxx ? This is not a issue of permissions. 403 should be returned for permission issue. What is the sub-status code of 404? – Bruce Zhang Jan 22 '21 at 07:37
  • I enabled Fail Request Tracing, but where or how can I see the log? This I will give you thé sub statuts and more details. – Fred Jan 23 '21 at 06:50
  • Please find the file req log file in my last edit (January 23). Thanks for your help. – Fred Jan 23 '21 at 09:48