Creating HTTPS web application

In this step by step tutorial, we are going to create a simple HTTPS web application using Fano CLI. Read Scaffolding with Fano CLI for more information.

Who is this tutorial for?

This tutorial is written for anyone new to Fano Framework. It is assumed that you have proficiency with Free Pascal and its language syntax. You are familiar with Linux command and and its shell terminal.


Create Project

Make sure that all requirements are met. To create a HTTP project using libmicrohttpd, run

$ fanocli --project-mhd=myhttps.fano

Wait until new project is created. If everything is ok, your project will be created inside myhttps.fano directory. Change active directory to myhttps.fano directory.

$ cd myhttps.fano

All actions below are assumed to take place inside myhttps.fano directory.

Create controller

Create main controller

$ fanocli --controller=Home --route=/

Setup SSL certificate

For our development purpose, we only need to use self-signed certificate. If you plan to have a publicly reachable server, you will need to ask a trusted third party, called Certificate Authority, to attest the certificate for you.

We need to create secret private key. We use OpenSSL to generate 1024 bit key. For our purpose, 1024 bit key is sufficient.

$ openssl genrsa -out myhttps.key 1024

If everything is ok, you should find myhttps.key file in current directory. Next we need to generate certificate using private key. Following command generate x509 certificate valid for one year.

$ openssl req -days 365 -out myhttps.pem -new -x509 -key myhttps.key

You will be asked serveral questions, make sure Common Name match URI of your domain. If command is successful, you should find myhttps.pem file in current directory.

Add SSL certificate in application

Open src/app.pas and edit lines like so

svrConfig.useTLS := true;
svrConfig.tlsKey := getCurrentDir() + '/myhttps.key';
svrConfig.tlsCert := getCurrentDir() + '/myhttps.pem';

Build application


$ ./

Wait until compilation is finished. If you get error such as,

/usr/bin/ld : cannot find -lmicrohttpd

You need to install libmicrohttpd development package first. Run after you install it.

Run application


$ ./bin/app.cgi

Access application from browser

By default, application listens on port 20477. Open web browser and go to Internet browser will show warning because we use self-signed certificate. Just allow and accept it and you should see text Home Controller is printed on browser.


In this tutorial, you have learned how to use Fano CLI to

  • Setup web application project directory with Fano Framework,
  • Create controller,
  • Create self-signed SSL certificate.
  • Add SSL certificate to application.

Explore more