#1 2017-11-27 12:02:43

Exilon
Member
Registered: 2016-10-11
Posts: 4

Deploy mORMot server on IIS75+

This is a simple solution to deploy mORMot server on IIS and let it control ip restrictions, https certificates, logs, etc...

Instructions to deploy:

- Create you mORMot server to get port number to listen from commandline first parameter.
- Install httpplatformhander https://www.iis.net/downloads/microsoft … ormhandler
- Create a folder and copy your mORMot server exe and files you need
- Configure IIS with domain and port you want to listen, cerfiticates etc. and set site path to folder where you copied your mORMot server.
- Create/edit web.config on this folder like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <remove name="httpplatformhandler" />
      <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
    </handlers>
    <httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\logs\ConsoleOut.log" startupTimeLimit="20" processPath=".\mORMotServer.exe" arguments="%HTTP_PLATFORM_PORT%"/>
  </system.webServer>
</configuration>

That's all! You have your app working with IIS!

All you need is a IIS7.5 or up with httpplatformhandler installed. This handler works as a reverse proxy, passing all requests to our application. Azure has installed this handler on its AppService plataform solution.

Benefits from having our app behind IIS:

- Binding on a especific ip, port and hostheader*
- Manage https certificates*
- Write W3C format log with all received requests
- URL Rewriting
- Every worker can raise an instance of your application
*can be managed with netsh, but with IIS is more simple.

This is the simplest way, but you can configure IIS with ARR (Application Request Routing) as a optional solution.

Offline

#2 2017-11-28 08:37:43

turrican
Member
From: Barcelona
Registered: 2015-06-05
Posts: 94
Website

Re: Deploy mORMot server on IIS75+

Exilon wrote:

This is a simple solution to deploy mORMot server on IIS and let it control ip restrictions, https certificates, logs, etc...

Thank you very much! Very nice way to deploy custom .exe WebServers using IIS as frontend web server.

Offline

#3 2018-01-13 16:45:19

HollosCs
Member
Registered: 2015-12-08
Posts: 56

Re: Deploy mORMot server on IIS75+

Hi, Exilon!
Please explain a bit more this method, I am very beginner in this area.
My test is not working. If possible send a mini mormot server source and explain IIS setting (convert to application, where set domain, port?)
Thanks, Csaba

Offline

#4 2018-01-14 13:02:53

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Deploy mORMot server on IIS75+

Great! A very helpful  reference!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#5 2018-01-15 12:41:22

Exilon
Member
Registered: 2016-10-11
Posts: 4

Re: Deploy mORMot server on IIS75+

HollosCs wrote:

Hi, Exilon!
Please explain a bit more this method, I am very beginner in this area.
My test is not working. If possible send a mini mormot server source and explain IIS setting (convert to application, where set domain, port?)
Thanks, Csaba

Hi HollosCs,

You are not limited to use mORMot DB server, you can use any base httpserver as THttpServer (Synopse), TidHttpServer (Indy), etc. Every time IIS opens your AppServer exe, it specifies a port number in commandline. Your AppServer needs to get this port number and use to configure httpserver:

//get port from commandline
Port := ParamStr(1);
//create server with port passed by commandline
myhttpserver := THttpServer.Create(Port,nil,nil,'MyServerName',8);

Make sure you have installed httpplatformhander on your IIS machine.

Configure your IIS site like this (here you can define ip, port and SSL certificate):

IIS Config

Change web.config file as i metioned above.

Configure your assigned application site AppPool as managed code:
IIS Config

Important: If your application needs write to disk or have access to any special resources, you need to configure appPool with an user with enough permissions.

Offline

#6 2018-04-17 19:53:47

HollosCs
Member
Registered: 2015-12-08
Posts: 56

Re: Deploy mORMot server on IIS75+

Hi, I'm back.
-Make an default, minimal THttpServer, read first param for port number
-Create directory, copy server.exe
-create web.config, set my server name
-Make new website and setting application pool

But in the browser: server not found
Nothing work. What I write the url bar?

Offline

#7 2018-04-18 01:12:30

xchinjo
Member
From: Thailand
Registered: 2016-04-29
Posts: 41
Website

Re: Deploy mORMot server on IIS75+

mORMot stop a few minute after start with IIS

Last edited by xchinjo (2018-04-18 10:30:06)


Jongruk Aripoo

Offline

#8 2018-04-18 07:33:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Deploy mORMot server on IIS75+

Please don't put such big amount of log inside the messages.
See again the rules https://synopse.info/forum/misc.php?action=rules

Especially if they don't show anything but a shutdown server.
From the logs, the server started, then immediately closed.
I guess that your code just do that: start the server, then free it.

Offline

#9 2018-04-18 09:47:58

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Deploy mORMot server on IIS75+

I use the URL Rewrite IIS module, I guess it's more flexible.
Follow this tutorial and it's very easy: https://tecadmin.net/set-up-reverse-proxy-using-iis/


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#10 2019-01-17 08:00:45

cefamax
Member
Registered: 2019-01-17
Posts: 1

Re: Deploy mORMot server on IIS75+

Hi, I use httpplatformhandler and it's ok if it's configured on the root of the site, but if I try on a subdirectory of the main site it does not work. Is there no way to configure the httpplatformhandler in a subfolder? If there must be other services (no mormot) in other subfolders in the same site, is it not possible to use httpplatformhandler?

Offline

Board footer

Powered by FluxBB