To use DEDS with IIS, you need to IIS with a few extras depending if it is for DG3 use, DataEase only or DataEase server. It can be used for any combinations. This documents describes how to install all needed for using DEDS with DataEase 9 and DEServer for making web sites. This setup can also be used with DG3v4 but then you have to do a few more steps manually to get it to work.

Setting up IIS for use with DEDS

Set up IIS as for server without any configurations. On Server 2019, what you need to do is run Server Manager and select Local server. Scroll down to the bottom where you find Roles and Features. Click Tasks on the right and select Add Roles and Features. Using installation type Role-based or feature-based installation on your local server.

Add role Web Server (IIS) with default and add Request Fitering and CGI (used for wfastcgi for DEDS). 

Start IIS Manager and Add Web Platform installer. From here add ARR and URL Rewrite in newest version.

Make sure you turn on Proxy support in Application Request Routing on top level for server in ISS Manager.

Install Microsoft IIS Administrator from http://go.microsoft.com/fwlink/?LinkId=829373 (in version 6.0.0 when this is written)

Setting up DEDS first steps

Install DEDS for IIS. 

Add license to C:\ProgramData\DataEase\DEDS

Open a command prompt and navigate to D:\DEDS\DG3DS

SET DJANGO_SETTINGS_MODULE=DG3DS.settings
SET PYTHONPATH=C:\DEDS\DG3DS
C:\DEDS\python.exe C:\DEDS\DG3DS\manage.py %1 %2 %3 %4

Check that you have a m.bat looking like this

Run m syncdb

Answer yes on create superuser and add the administrator to use on the system.

Set up IIS Administrator API for use with DEDS

If you change user login for server after it is set up, you will have add this user to the "IIS Administration API Owners" group in the server. To get to this local group use lusrmgr.msc from "Type here to search".

Generate a access token in API Explorer found at https://localhost:55539 that never expires

This can be done by starting the server using with "m runserver 0.0.0.0:81 --noreload" from same place as you set ut up. Then just point your browser to 127.0.0.1:81 and you should be taken to the setup page. If not it can be found at http://127.0.0.1:81/appmanager/showsettings/ where you can change all relevant settings.

Or you can do it manually by adding this to deploy.conf in C:\ProgramData\DataEase\DEDS with key iisapi together with the user name and password your used to login to api explorer at the key iisapiuser and iisapipw.

"""
Configuration file
Created at to day date and time
"""
settings = {
    'lastusedfcgiport' : 3033,
    'version' : 0.1,
    'webservertype' : u'iis',
    'usesiteredirect' : False,
    'serverkey' : 'thekeyyouwilluseasmasterkeyfordoingthingstotheserver',
    'iisapi' : 'thekeyyougotfromiisapiexplorer',
    'iisapiuser' : 'adminuser',
    'iisapipw' : 'adminpassword',
}

Then it should look a like this. Now DEDS is ready to be used standalone if you do not want to have it behind IIS. To start it up just run "m runserver 0.0.0.0:81 --noreload" and it will start up on port 81 and be ready to use from there if you open the firewall. but it is better if you set it up behind iis, give it a dns name and https.

Setting up DEDS for use behind IIS as default web site

Add web.config to C:\inetpub\wwwroot with the following in it to install DEDS as wfastcgi app on servers Default web site

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="Python FastCGI"
        path="*"
        verb="*"
        modules="FastCgiModule"
        scriptProcessor="c:\DEDS\python.exe|c:\DEDS\lib\site-packages\wfastcgi.pyc"
        resourceType="Unspecified"
        requireAccess="Script" />
    </handlers>
  </system.webServer>
  <appSettings>
    <!-- Required settings -->
    <add key="WSGI_HANDLER" value="DG3DS.wsgi.application" />
    <add key="PYTHONPATH" value="C:\DEDS\DG3DS" />
    <!-- Optional settings -->
    <add key="DJANGO_SETTINGS_MODULE" value="DG3DS.settings" />
    <!-- <add key="WSGI_LOG" value="C:\inetpub\Logs\DEDS.log" /> -->
  </appSettings>  
</configuration>

Since we have added the config files manually, we need to unlock the handlers we have added. 

To do this click on your server name in IIS Manager (not the site) and then Configuration Editor. 

Then locate system.webServers/handlers and press Unlock Section on the right. Now it is done for this server, so any DG3 application added do not need to do the same.

The next step is to give the web server rights to run DEDS. This is done by adding the "IIS AppPool\DefaultAppPool" (the apppool for the Default Web Site) to C:\DEDS with "Full control".

Next we need to do the same for C:\Inetpub and C:\ProgramData\DataEase\DEDS.

Next to let DEDS have admin rights, the user must be added to the Admin group. This is done by running lusrmgr.msc form start or Server Manager -> Tools -> Computer Management -> Local Users and Groups -> Groups -> Administrators. Then add "IIS AppPool\DefaultAppPool" to the the Administrator group.

Now deds are setup on default web site and can be reached by the ip address of the server. You can try it by going to http://127.0.0.1/ and logging in with the user name and password given during setup.

If you still get a 500 internal error when running behind iis, you can locate the C:\Windows\System32\inetsrv\config\applicationHost.config and locate system.webserver grout and make sure the hander is set to Allow.

<sectionGroup name="system.webServer">
...    
    <section name="handlers" overrideModeDefault="Allow" /><br>

Make sure DEDS is responsive

To make sure that the DEDS server instance do not stop, we need to turn of Idle-Time timeout in DefaultAppPool. This is done by going to Application Pools, click on the DefaultAppPool and select Advanced Settings. Down in the list you will find Idle Time-out (minutes) 20. This should be changed to 0 for no time out.

Set up virtual directory for static files in DEDS

DEDS have a few libraries and static files that need to be served by IIS. To set up that, select the site in IIS Manager and select "Add Virtual Directory" on the right click menu.

Set Alias to static and Physical path to C:\DEDS\DG3DS\static

Set up DEServer for use with DEDS

Install latest version av DEServerLive

Add license to C:\ProgramData\DataEase\deserver

Then all is set to go. Next is to use DEDSScripts in you DataEase to deploy to this server or DG3v4.

Setting up DEDS with a proper name

The final setup to make it all complete is to add a proper name and SSL to the server.

First add a name pointing to your server in DNS. It should be a A record with a name like deds123456.your.domain that point to the ip address your server can be reached from on the internet.

Next add this name as a binding to Default Web Site by using IIS manager -> click on site Default Web Site and then click on Bindings on the right. Press Add and add the domain name to Host name in the form my.name.domain

Setting up DEDS with SSL

Next is to open a command prompt and go to "C:\DEDS\win-acme2" that is under DEServer and start wacs.exe.

Select N to create the certificate

Select 1 for Default Web Site

Select A for All binding and y

Since this is the first setup you need to add email address and n to open terms (unless you want to read them) and y to agree.

Unless problems that is it, you need to check that things are renewed automatically but you should get e-mails to remind you if problems occurs.

Next is to remove http the two http bindings to leave only the https one to be used. Go to Bindings and Press remove for to to using http.

Setting up http to https redirect

If you want to be able to find the server on http you can do a redirect from http to https instead. This is how you set up a rule to redirect all requests from http to https:. This one makes are rule that will redirect any request the is not https to https. Also a reverse rule that take them all to https.

Open IIS Manager and select the sit to redirect to https.

Select URL Rewrite and "Add Rule(s)..." to add a Blank rule

Give it a name like "Redirect to HTTPS"

In the Match URL section set:

Requested URL: Matches the Pattern
Using: Wildcards
Pattern: *
Ignore case: Checked

In Conditions section set:
Logical grouping: Match Any

Press "Add" and add to the dialog
Condition input: {HTTPS}
Check if input string: Matches the Pattern
Pattern: OFF
Ignore case: Checked
Track capture groups across conditions: Not checked

Leave Server Variables blank
In Action section set:
Action type: Redirect
Redirect URL: https://{HTTP_HOST}{REQUEST_URI}
Append query string: Not checked (since this already are a part of REQUEST_URI)
Redirect type: Permanent (301)

After Apply make sure to move it to the top as this needs to be done before any other rule