PortLab

Platform for Open Research Through Live Analysis and Broadcasting

PortLAB

PortLAB is the platform used at CNR-IFAC (Institute of Applied Physics «Nello Carrara») to build and manage scientific portals: a single engine, written in PHP with a PostgreSQL database, from which different websites arise — multilanguage, responsive and rich in interactive content — while sharing structure, style and tools.

What it is

PortLAB is a lightweight framework for building portals. Each page is defined by a small declarative configuration (in JSON) that sets its structure, languages, libraries and access levels, while the content lives in separate per-language files. This makes it possible to add pages and whole sites quickly, keeping visual and functional consistency and without touching the engine.

Projects built with PortLAB

  • WebNIR (webnir.eu) — CNR-IFAC portal on non-ionizing radiation: electromagnetic fields (EMF), artificial optical radiation (AOR) and active implantable medical devices (AIMD), with tools for exposure and shielding assessment.
  • Purple (purplecodex.eu) — a portal on non-invasive analytical methods applied to cultural heritage, for the study and cataloguing of the codices purpurei, manuscripts written on purple-dyed parchment.
  • UISH — Urban Intelligence Science Hub (uish.ifac.cnr.it) — a CNR project for the digital twin of the city: CNR-IFAC's activity on air quality in Catania and the validation of the AirPortal model.
  • Eclipsis (eclipsis.ifac.cnr.it) — a portal devoted to the solar eclipse of 12 August 2026 observed from La Coruña: the reduction chain for the RAW photographs, from shot metadata to ephemerides, run on the server.
  • Satellite (satellite.ifac.cnr.it) — the restricted workspace of a multi-partner project proposal: partner institutions, work packages, people and person-hours, costs, with the Gantt chart built from the data.
  • Administration console — the management interface of the platform itself, which also hosts an educational section with interactive examples.

Project-based architecture and customisation

PortLAB is organised around a main site that acts as a shared base for all the secondary projects hosted on the platform. Each project has its own content and its own local customisations, but automatically inherits from the main site both the common code and the third-party libraries, shared only once and maintained centrally: no duplication and immediate updates for everyone. At the same time, each project can customise any element at any point, selectively and independently replacing the shared version with its own local one. The result is a layered architecture — local elements, common elements and shared libraries, freely combinable — that makes it possible to launch new portals quickly while keeping a tailored identity and look for each.

Beyond the common code and libraries, the services and tools offered by PortLAB (database management and viewing, schema diagram, user management, log inspection and more) can also be inherited by secondary projects through symbolic links to the main project: every new portal thus gets the full toolset with no duplication, while still being able to replace or extend any part locally.

PortLAB layered architecture The main site shares common code, third-party libraries and services with the secondary projects, which add local content and customisations. Project A Local content Customisations Project B Local content Customisations Project C Local content Customisations inherits via symbolic links MAIN SITE — shared base Common code Third-party libraries Services and tools
Layered architecture: a shared base from the main site, customisable locally by each project.
Graphical interface (GUI)

The interface is made of standard Bootstrap-based elements — headers, navigation bars, menus, breadcrumbs, footers and modal dialogs: independent, reusable building blocks to be combined until the desired page structure is obtained, with visual consistency and full responsiveness.

Template

The template is the page model: it sets which interface elements to use and how to lay them out, including the type of menu (horizontal at the top or on the side) and the overall style. Each template is a predefined, reusable combination of components, called by a page with a simple reference; changing template changes the look and layout of the whole page without touching its content.

Anatomy of a page The template combines the interface building blocks: header, navigation bar with menu, breadcrumb, body with an optional side menu, and footer. Header Navbar + menu Breadcrumb Side menu(optional) Page body Footer
The template selects and combines the interface building blocks (GUI) to form the page.
Page descriptor

Every page is declared by a small JSON file, and the declaration is not a formality: without that file the page does not exist for the platform and its address answers «not found». It is the first link in the access control chain. The descriptor says which template to use, who may open the page, what to load and in which order, and how the page presents itself in the menu.

{
  "template": 18,
  "profiles": [1],
  "flags": { "menu_order": 3 },
  "libs": {
    "css":    ["/css/common/editor_svg.css", "/css/common/diagram.css"],
    "js":     ["/js/libs/ace-builds-master/src-min-noconflict/ace.js"],
    "js_end": ["/js/common/editor_svg.js", "/js/common/diagramma.js", "/js/common/diagram_ui.js"]
  }
}
  • template — the page model described just above.
  • profiles — the authorised profiles. An empty list means a public page, not an unreachable one: it is the only opening, and it has to be written on purpose.
  • libs — the page's own stylesheets and scripts, in the exact order in which they are to be loaded, with js before the page body and js_end after it. The base shared by every page (jQuery, Bootstrap, select2, the menu, search, login, language, dialogs) is not listed: the platform writes it before these, so it is updated in one place only.
  • flags.hide_in_menu — the page stays reachable by address but does not appear in the menu.
  • flags.menu_order — the page's place among the files of its folder: ascending number and, on a tie or with no number at all, ordering by name. The name always breaks the tie, so a wrong number moves one entry and does not rearrange the section. Its purpose is to keep the ordering out of file names, which are also addresses. Folders, which have no json, take their number from the menu_order map in the project's protect/struct.json; with a number they mix with the files, so a page can also come after a folder.

Everything else is not configuration but files recognised by their name: the page body, one per language; a dictionary for the strings of the Javascript interface; and, if needed, a server-side logic file. Adding a page therefore means creating files, not editing a central register — which is why the menu, the breadcrumb and the search engine find it on their own.

Users, access and navigation

Multi-profile user management

Each user can be assigned several authorization profiles. A resource is accessible when at least one of the user's profiles matches one of the profiles required by the resource; pages with no profiles remain public. The same rule uniformly governs access to pages and sections, menu entries, downloadable files and even the visibility of individual portions of a page: the same page can thus show different content to users with different profiles.

Authentication and passwords

Every site belongs to an authentication cluster, which states where the users' credentials are kept, which external identity providers can be used to log in and which rules apply to passwords. The sites of the same cluster share the accounts; a cluster in libero mode has no authentication, and its sites have neither login nor sign-up.

The password rules are chosen per cluster: the minimum length, the required character classes (counted in Unicode, so accented letters and other alphabets count too), the ban on personal data and on the most common passwords, expiry, the history of recent passwords and how much the new one must differ from the previous one. The hash is Argon2id wherever PHP offers it, and a password is never truncated. Whoever logs in with a password that has expired, or that no longer follows the rules, must change it before getting a session.

Single sign-on and external providers

One site can act as the centre of single sign-on: the sites of its cluster that join it recognise whoever has logged in there and receive the session through a single-use ticket valid for sixty seconds. Each site keeps its own session cookie, and logging out applies to all of them. On the centre one can also log in with an external identity provider (OpenID Connect; ORCID and Google are provided for). The provider does not create accounts: an external identity opens a session only if the user, logged in with the password, has linked it to their own account.

Reserved area

Public pages are clearly separated from the application code and from reserved content, kept in an area located outside the web root and therefore not reachable directly from the browser. Reserved documents are never exposed as static URLs: they are delivered exclusively by server-side procedures that, before sending, verify the user's identity and profiles.

Security and cryptography

Protections are cross-cutting: sessions secured with anti-CSRF tokens, session-id regeneration and cookies with security attributes (HttpOnly, Secure, SameSite); passwords kept only as hashes; query parameters validated and constrained. Reserved content and «capability» links are protected with standard cryptography (AES-256-GCM: every token carries its purpose and its expiry, and is not valid for another use) and keys kept outside the source code. Access control is fail-closed: a page is reachable only if explicitly configured, and even the server-side computation endpoints are subject to the user's profiles. Errors have pages of their own (400, 403, 404, 413, 500 and 503), which depend neither on the session nor on the database; the one for a page not found leads back to the home page.

Against password guessing there is a lockout after failed attempts: five failures in fifteen minutes lock the account for fifteen minutes, but only from browsers the site does not know. The browser from which the user has already logged in is recognised by an encrypted cookie and has its own counter, so whoever tries passwords on an account does not lock out its owner logging in from the usual browser. No response reveals whether an address is registered.

Every response carries the security headers: HSTS and nosniff from the web server, X-Frame-Options, Referrer-Policy, Permissions-Policy and the Content Security Policy from PHP. The policy allows scripts, styles, images, fonts and connections only from the site itself and from the origins it declares; it starts in report-only mode, with the violations collected in a log that the Diagnostics page summarises, and it is enforced once the log stays clean. Alongside it a stricter one is being tried, which requires on every script of the page a nonce that is new at every request, and is in turn enforced once its own log stays clean.

Dynamic generation of the navigation menu

The menu is not hand-written: it is built automatically by exploring the tree of folders and pages. Every new page appears on its own, organised on multiple levels according to nesting; entries are filtered by the user's profile and by a dedicated exclusion flag, and the titles are taken from the page in the chosen language. Without numbers, files come before subfolders, each in order of name. A page takes a number from its descriptor, a folder from the project's map: numbered entries, files or folders, come first, by number and by name on a tie. A section is therefore reordered by changing a number, with no file renamed and no address moved.

Content, search and privacy

Multilanguage support

The available languages are declared per page. The body of each page lives in a separate file for each language, while the interface strings are handled by a dictionary-based translation system that works identically in PHP and Javascript: the same function and the same dictionaries are available both on the server and in the browser. This makes it possible to translate on the fly any string, from any section of the page — including those produced by Python or C++ programs run through the gateway (gw2py) and returned to the page.

An extension for parametric strings is also available: the translated text contains numbered placeholders (e.g. {0}, {1}) replaced at runtime with the actual values. This is essential because in different languages the parameter may take a different position in the sentence: the placeholder is put where each translation needs it, so the text stays natural (for example «{0} elementi trovati» in Italian becomes «found {0} items» in English, with the value in different places). The whole pipeline is UTF-8, so any alphabet can be hosted; the languages in use today are Italian, English and Spanish, and each portal has one, two or three of them, with a flag-and-code language selector.

Built-in text search

By typing at least three characters, the system scans the site pages in the selected language (or in all of them, with the corresponding option) and shows the results in a dedicated window. For each page an excerpt is presented with title, keywords, description and text in which the searched term appears, highlighted in its context, with a direct link to the page. Besides the text, the search looks at the data the page embeds and, with the «Include SVG» option, at the texts of the SVG drawings the page shows. The search correctly handles international alphabets and characters (UTF-8) and can be targeted, page by page, to the relevant paragraphs only.

GDPR management

PortLAB includes ready-to-use GDPR handling: a dedicated privacy/cookie notice and a consent banner reused by all sites. The platform is set up to use technical cookies only, with no profiling or third parties; the banner is purely informative, does not block navigation and remembers acknowledgement for a set period.

Database tools (PostgreSQL)

Table management

A single reusable interface makes it possible to create, edit, delete and browse the rows of the database tables, with multi-criteria filtering, customisable sorting, pagination and JSON import/export of the criteria. The consoles that provide for it export the filtered rows to CSV, for the profiles the site allows.

Data viewing and exploration

A complete database viewer brings together four tools: a navigator that explores databases, schemas, tables, views, materialized views and functions through an interactive tree and cascading filters (showing structure, types, keys, sizes and definitions); an SQL query executor with an advanced editor, direct execution and CSV export of the results; a library of stored queries recallable with one click; and a keyword search across all fields, with filters by schema, table, field and data type.

Graphical schema diagram

A graphical viewer generates an interactive diagram of the schema: each table or view is a node listing its fields with the primary key highlighted. Nodes can be dragged freely on the work surface and the links between related fields are drawn as lines; layout, colours and links are saved and restored at every visit.

Administration and diagnostics

Server log inspection

An administration console makes it possible to inspect the logs of the web server, Apache or Nginx — accesses and errors — filtering the lines by inclusion or exclusion of a string, with the option to hide informational messages or to clear the log; a dedicated section shows the server's PHP configuration. Access is restricted to administrators.

Diagnostics and alert

A Diagnostics page runs some seventy checks on the installation: configuration of the web server and of PHP, folder permissions, databases and roles, libraries, consistency of pages and dictionaries, security. For many of them it gives the command that fixes what is missing. An alert runs them by itself once a day and, when a check changes state, writes to the addresses chosen among those of the administrators; on Mondays it sends a summary, and if it cannot run it says so all the same.

Standardised error messages

Every critical point in the code — SQL queries, PHP operations, calls to the Python gateway, client-side scripts — is marked with a code/index: when something goes wrong a uniform message reports that code, making it possible to pinpoint exactly where the problem occurred. Messages are tailored to the profile: a regular user sees an essential notice with the code, while the administrator is also shown the technical details (type, file, line, query text) useful for debugging. The mechanism is uniform for both pages and AJAX calls.

Technology

At the heart of the server side is a gateway that lets pages invoke, in a uniform way, programs and computations written in different languages — so far Python and C++ — returning the results (usually as JSON) directly into the page. The gateway is used pervasively together with jQuery's AJAX interface: this has effectively standardised the calls across the whole portal, with a single request/response scheme for any dynamic operation.

  • Engine in PHP on Apache or Nginx and Linux, PostgreSQL database; front-end on Bootstrap 5 and jQuery.
  • Pages configured declaratively (JSON): template, metadata, libraries and access profiles, without changing the engine.
  • Reusable components and server-side computation via a Python gateway: pages can launch simulations and processing and display the results.
  • Interactive scientific content: charts (ECharts), LaTeX formulas (KaTeX), 3D visualizations (three.js), syntax-highlighted code, result tables to download as PNG or XLS, built in the browser without going through the server.
  • A wizard to start new portals; responsive layout for desktop and mobile.
Technology stack The browser talks over HTTP/AJAX to the Apache/PHP server, which queries the PostgreSQL database and delegates computation to a gateway that runs programs in different languages. Browser Bootstrap · jQuery ECharts · KaTeXthree.js · highlight Server Apache + PHP PortLAB engine Profiles · session PostgreSQL Data · usersschemas, tables, views Gateway (gw2py) compute: Python, C++ HTTP / AJAXSQL
From browser to database: the PHP engine orchestrates data and computation; the gateway runs programs in several languages.

PortLAB is installed on your own server with a script. Here you prepare the zip: the copy of PortLAB and the parameters of your installation, in a single file.

What you type on this page stays in your browser. The fields are not sent to any server, not even ours. Your browser builds the zip: it takes the copy of PortLAB from the site, which is the same for everyone, and adds the parameter file to it. The zip contains the passwords you type: keep it as you would keep a password, and delete it after the installation.

In three steps

  1. Fill in the parameters below and press "Prepare the zip".
  2. Copy the zip to the server and unpack it.
  3. Run the script as root. It installs the packages, creates the database, sets up the chosen web server, Apache or Nginx, and the certificate, and finally tests the home page.
Downloading the copy is reserved to the portal administrators. The instructions below are for everyone.

Instructions

What you need
  • A server with Ubuntu 26.04 LTS and root access. Ubuntu 26.04 has PHP 8.5 and PostgreSQL 18 in its own archive, so no external repositories are needed.
  • A domain name pointing to the server is only needed for the Let's Encrypt certificate, which checks the domain on port 80: that port must be reachable from the Internet. Without it, the script installs a self-signed certificate. The site answers on 443, which must be open to its users.
  • Outbound Internet access during the installation: the script downloads the Ubuntu packages (apt), the PHP libraries (Composer) and the Python ones (pip).
  • A mail server for the site's e-mails, with host, port and encryption and, if it asks for them, user and password. Without it the site works, but sign-up and password recovery send no e-mail.
The commands

From your computer, copy the zip to the server and log in:

scp portlab-<name>.zip user@server:
ssh user@server

On the server, unpack and run the script as root:

python3 -m zipfile -e portlab-<name>.zip .
sudo bash portlab/webadmin/install/install.sh
rm portlab-<name>.zip

Unpacking only needs Python, which Ubuntu already has. The last line deletes the zip, which contains the passwords; the script deletes the parameter file when it has finished.

What the script does
  1. Checks the parameters. If one is wrong it stops and lists them, before touching anything. The administrator's password follows the site's initial rules: at least 8 characters, with a lower-case letter, an upper-case letter, a digit and a character that is neither a letter nor a digit, and at most 72 bytes if the server's PHP lacks Argon2id.
  2. Installs the packages: the chosen web server (Apache, or Nginx with PHP-FPM), PHP and the Python gateway, PostgreSQL, Composer, WeasyPrint, the fonts for PDFs, pdftotext and certbot.
  3. Creates the user and copies the files into the chosen folder, which becomes the user's home directory, with the PHP and Python libraries.
  4. Creates the database: the four roles (the owner with no login, the personal user, the roles the pages write and read with), the schema, the reference data (languages, locales, regular expressions, profiles), the authentication cluster with the initial password rules, the site with its languages and profiles, the database connection and the administrator.
  5. Writes the configuration: the token key, the database credentials for the web server, the site name, mail, robots.txt and security.txt.
  6. Sets up the web server and requests the certificate. With Apache it writes the vhost the Diagnostics expect and opens the PortLAB folder to it for writing with a systemd rule (needed when the folder is under /home, which Ubuntu 26.04 keeps read-only for Apache; elsewhere it changes nothing). With Nginx it writes the server block with the same rules, the PHP-FPM pool and the systemd service of the Python gateway, portlab-gw-<name>.
  7. Sets the permissions of the folders the web server writes to, and schedules the daily jobs: at night the clean-ups and the search index, at 06:30 the Diagnostics alert, which runs the checks by itself and writes to the administrator's address given in the form.
  8. Tests the home page and prints the site address. If the script generated the administrator password, it prints it here, only once.
After the installation

Open the site, log in with the administrator's address and password and open Management > Projects > Diagnostics. It tells you what is left to fix, and for many checks it gives the command that fixes it. The alert already writes to the administrator's address: in the «Alert» panel of the same page you choose the addresses of the other administrators and the language of the emails.

If something goes wrong
  • It can be run again. The script repeats its steps without deleting anything: the token key stays the same, and the database schema is not reloaded if it is already there. The parameters must be put back, though, because the file has been deleted.
  • The certificate does not arrive when the domain does not point to the server yet or port 80 is closed. The self-signed one stays; once DNS is fixed, just run the script again.
  • The home page does not answer: the reason is in /var/log/apache2/error.log (with Nginx, in /var/log/nginx/error.log).
  • With Nginx the pages open but the calculations do not start: the Python gateway is a separate service. systemctl status portlab-gw-<name> tells whether it is running, and the Diagnostics check it (Python gateways of the sites).
  • The log says “Read-only file system”: the PortLAB folder is under /home, /usr or /etc and Apache lacks the systemd rule that opens it (see Setting up by hand).
The packages

The script installs them by itself. If you prepare the server by hand, or want to know what gets installed, here is the complete list.

System packages (Ubuntu 26.04)
PackageWhat it is for
apache2the web server
libapache2-mod-php8.5PHP inside Apache, for the pages
libapache2-mod-wsgi-py3the gw2py Python gateway inside Apache
php8.5-clicommand-line PHP: the script, the search index, the nightly jobs
php8.5-pgsqlPHP with PostgreSQL
php8.5-gdimages: thumbnails and charts
php8.5-mbstringUTF-8 text
php8.5-curlrequests from the server to other sites: Diagnostics, sign-in with external providers
php8.5-xmlXML, for spreadsheets and imports
php8.5-zipthe zip archives of spreadsheets
php8.5-bcmatharbitrary-precision arithmetic
php8.5-intldates and numbers written according to the language
postgresqlthe database, with the pg_trgm, dblink and postgres_fdw extensions
python3-venv, python3-pipthe gateway's Python environment and its packages
composer, unzipthe PHP libraries: PHPMailer for mail, PhpSpreadsheet for spreadsheets
rsynccopying the files into the chosen folder
ssl-certthe self-signed certificate, if Let's Encrypt does not answer
certbotthe Let's Encrypt certificate and its renewal
librsvg2-binrsvg-convert, which makes the PDFs of the diagram and Gantt editors
fonts-ibm-plex, fonts-roboto, fonts-jetbrains-mono, fonts-nunitothe fonts of those PDFs
weasyprintPDFs made from HTML pages, for the projects' exports
poppler-utilspdftotext, which reads the text of the site's PDFs for the search
g++, makethe C++ programs the gateway can run
curlthe home-page test at the end of the installation, and every day the call of the Diagnostics alert
ca-certificatesthe authorities that sign certificates: mail, Let's Encrypt, CDN

By hand, all together:

sudo apt install apache2 libapache2-mod-php8.5 libapache2-mod-wsgi-py3 \
  php8.5-cli php8.5-pgsql php8.5-gd php8.5-mbstring php8.5-curl php8.5-xml php8.5-zip \
  php8.5-bcmath php8.5-intl postgresql python3-venv python3-pip composer unzip rsync ssl-cert \
  certbot librsvg2-bin fonts-ibm-plex fonts-roboto fonts-jetbrains-mono fonts-nunito poppler-utils \
  weasyprint g++ make curl ca-certificates

With Nginx three packages change: instead of apache2, libapache2-mod-php8.5 and libapache2-mod-wsgi-py3 these two are installed, and the rest of the list is the same.

PackageWhat it is for
nginxthe web server
php8.5-fpmPHP as a separate service, to which Nginx passes the pages

The Python gateway has no package of its own: it runs in the Python environment below, as a systemd service.

Python packages of the gw2py gateway

The gateway runs in its own Python environment, <folder>/venvs/webadmin, with the same Python as mod_wsgi. The packages are listed in wsgi-scripts/requirements.txt:

PackageVersionWhat it is for
multipart2.0.0reads the forms and files the pages send to the gateway: the only package gw2py needs
psycopg2-binary2.9.12PostgreSQL from Python, for the console generator (gen_table_page.py)
waitress3.0.2the gateway without mod_wsgi (pyapp_server.py): in development, and in production with Nginx

The rest of the gateway (authorisation, long jobs, the PDF converter, the image checks) uses only the Python standard library. By hand:

python3 -m venv /srv/portlab/venvs/webadmin
/srv/portlab/venvs/webadmin/bin/pip install -r /srv/portlab/wsgi-scripts/requirements.txt
Setting up Apache or Nginx, PHP and PostgreSQL by hand

The script does everything by itself. If you prefer to do it by hand, or want to see what it writes, the zip has the files already filled in with the form's parameters in the portlab/conf folder. The commands below use the default values (the /srv/portlab folder, the boot database): change them if yours are different.

Apache
  • conf/apache/<name>.conf: the http vhost, which sends everything to https except the checks Let's Encrypt uses to verify the domain;
  • conf/apache/<name>-ssl.conf: the https vhost, with the Python gateway, the security headers and the protected folders. It is the one the Diagnostics expect.

First the http vhost and the certificate, then the https one, which already names the certificate files:

sudo a2dismod mpm_event
sudo a2enmod mpm_prefork ssl headers wsgi php8.5
sudo cp portlab/conf/apache/*.conf /etc/apache2/sites-available/
sudo a2dissite 000-default
sudo a2ensite <name> && sudo systemctl reload apache2
sudo certbot certonly --webroot -w /srv/portlab/website -d <domain> -m <e-mail> --agree-tos
sudo a2ensite <name>-ssl && sudo apachectl configtest && sudo systemctl reload apache2

With the self-signed certificate the certbot step is not needed: the https vhost uses the one from the ssl-cert package.

On Ubuntu 26.04 systemd puts Apache in a cage: among other things /home, /usr and /etc are read-only, and the site cannot write to its folders even with the right permissions (in the log: “Read-only file system”). The rule conf/systemd/portlab-<name>.conf opens the PortLAB folder to it again; where it can write is still decided by the file permissions. With the default folder, /srv/portlab, the rule is not needed and changes nothing: the script writes it anyway.

sudo mkdir -p /etc/systemd/system/apache2.service.d
sudo cp portlab/conf/systemd/portlab-<name>.conf /etc/systemd/system/apache2.service.d/
sudo systemctl daemon-reload && sudo systemctl restart apache2
Nginx

With Nginx chosen in the form, the zip has these files in portlab/conf instead of the Apache ones:

  • conf/nginx/conf.d/portlab.conf: the long-cache rule for css and js files, one per machine;
  • conf/nginx/sites-available/<name>.conf: the server block, with the same rules as the Apache vhost. It is what the Diagnostics expect;
  • conf/php/fpm/pool.d/portlab.conf and conf/php/fpm/99-portlab.ini: the PHP-FPM pool of the sites and its settings;
  • conf/systemd/portlab-gw-<name>.service: the Python gateway as a service. Nginx does not run Python: the gateway runs on its own, and Nginx passes it the requests.

First PHP-FPM and the gateway, then Nginx:

sudo cp portlab/conf/php/fpm/99-portlab.ini /etc/php/8.5/fpm/conf.d/
sudo cp portlab/conf/php/fpm/pool.d/portlab.conf /etc/php/8.5/fpm/pool.d/
sudo systemctl restart php8.5-fpm
sudo cp portlab/conf/systemd/portlab-gw-<name>.service /etc/systemd/system/
sudo systemctl daemon-reload && sudo systemctl enable --now portlab-gw-<name>
sudo cp portlab/conf/nginx/conf.d/portlab.conf /etc/nginx/conf.d/
sudo cp portlab/conf/nginx/sites-available/<name>.conf /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/<name>.conf /etc/nginx/sites-enabled/
sudo rm -f /etc/nginx/sites-enabled/default

The server block already names the certificate files. With the self-signed one, sudo nginx -t && sudo systemctl reload nginx is enough. With Let's Encrypt the certificate is not there yet, and Nginx would not start: for the first start put the self-signed one in, request the certificate, and put the file back as it was.

F=/etc/nginx/sites-available/<name>.conf
sudo sed -i.le -e 's#^ *ssl_certificate .*#    ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;#' \
  -e 's#^ *ssl_certificate_key .*#    ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;#' $F
sudo nginx -t && sudo systemctl reload nginx
sudo certbot certonly --webroot -w /srv/portlab/website -d <domain> -m <e-mail> --agree-tos \
  --deploy-hook "systemctl reload nginx"
sudo mv $F.le $F
sudo nginx -t && sudo systemctl reload nginx

Three things to know. After changing the gateway's .py files, restart its service (sudo systemctl restart portlab-gw-<name>): the long calculations in progress keep running. Nginx does not read .htaccess files: the extensions the site serves from /download/ stay listed in website/download/.htaccess and must be repeated in the server block; the Diagnostics warn when the two lists differ. And protect/apps/installazione.json must say "server": "nginx" (the script writes it by itself): from there the Diagnostics know which files and which logs to read.

PHP

The settings are in two files, one for the site and one for the command line:

sudo cp portlab/conf/php/apache2/99-portlab.ini /etc/php/8.5/apache2/conf.d/
sudo cp portlab/conf/php/cli/99-portlab.ini /etc/php/8.5/cli/conf.d/
sudo systemctl reload apache2

The site file also has session.upload_progress.enabled = Off: upload progress written into the session is the classic way to make PHP write attacker-chosen bytes into a session file (the Italian CSIRT flagged it too, in October 2026); it is not a defect an update fixes, it is the intended behaviour, and PortLAB does not use it: the browser computes the percentage. Switch it off wherever PHP runs. With PHP-FPM any file in /etc/php/<version>/fpm/conf.d/ holding that line will do, then systemctl reload php<version>-fpm; to close it against a .user.ini as well, put php_admin_flag[session.upload_progress.enabled] = off in the pool. With mod_php and AllowOverride None no .htaccess can turn it back on. Check with php-fpm<version> -i | grep upload_progress, or in the site's phpinfo page.

SettingValueWhy
post_max_size, upload_max_filesize200Mthe measurement files and images being uploaded
max_file_uploads200many files in a single upload
memory_limit512Mthe limit of one request; the pages that read large files raise it themselves
session.gc_maxlifetime43200the session lasts 12 hours without activity, as PortLAB expects
expose_php, display_errorsOffno version in the responses and no errors in the pages: they go to the Apache log
date.timezonethe form's time zonethe dates of e-mails and logs
pcre.jit0for the site only: Apache's systemd cage gives no executable memory, and compiling regular expressions would fill the log with warnings

The extensions needed are pgsql, gd, mbstring, curl, xml, zip, bcmath and intl (the php8.5-* packages), plus sodium and openssl, which PHP already has. The Diagnostics check them one by one.

PostgreSQL

PortLAB wants PostgreSQL 18 on the same machine, reached over TCP on localhost with a password. On Ubuntu the default values are already fine:

  • listen_addresses = 'localhost' in postgresql.conf: the database is not opened to the network;
  • host all all 127.0.0.1/32 scram-sha-256 in pg_hba.conf: the pages log in with the passwords of the .pgpass file.

The database is created by the files in webadmin/install/sql, in this order. Each one states at the top which psql variables it needs (names and passwords of the roles, the site, the administrator): install/database.sh passes them by itself.

  1. 01_database.sql, as postgres: the four roles, the database (owned by the owner) and the pg_trgm, dblink and postgres_fdw extensions. The owner has no login and no password; the personal user is a member of it without inheriting its privileges, and the role set for the database makes it work as the owner as soon as it logs in (pgAdmin, QGIS, psql); the page roles cannot become it;
  2. 02_schema.sql, with the owner's role, which owns everything;
  3. 03_permessi.sql, as postgres: rows, not tables, for the writing role (SELECT, INSERT, UPDATE, DELETE, TRUNCATE and MAINTAIN, no CREATE, ALTER, DROP), read access only for the reading role, also for the objects the owner will create;
  4. 04_dati.sql, as postgres: languages, flags, locales, time zones, the physical quantities with their units and the SI prefixes (metrology schema), regular expressions and profiles;
  5. 05_sito.sql, with the writing role: authentication cluster 1 «PortLAB», with the users in the users schema of boot, the initial password rules and no external provider; the site, its languages and its profiles; the boot connection; the administrator.

The web server finds the credentials in /var/www/.pgpass, owned by www-data with permissions 0600. Each line has a header above it: #conn_p for the reading role, #conn_a for the writing one.

#conn_p
localhost:5432:boot:portlab_ro:<password>
#conn_a
localhost:5432:boot:portlab_rw:<password>

On a dedicated machine shared_buffers can be given a quarter of the memory; for the rest, Ubuntu's values are enough. Database backups are made with pg_dump, for example every night: sudo -u postgres pg_dump -Fc boot > /var/backups/boot.dump.

Licences

The PortLAB code is distributed under the EUPL-1.2 licence, the content under CC BY 4.0; third-party libraries have their own, listed in the LICENSES folder of the copy. The JavaScript libraries come from jsDelivr, with the fingerprint the browser checks.

Some of PortLAB's mechanisms can be tried here, on this very page: what happens when you press the buttons is the real behaviour of the site, not a simulation.

Keyword search and $id_search

Every page declares which parts of itself enter the search: the title, the keywords, the description and only the pieces of the body listed in the $id_search variable. So the texts are searchable, while interface controls, formulas and code blocks stay out and do not pollute the results. This holds for the live search and for the index the site builds every night. The two boxes below each contain an invented word that appears on no other page: the first sits in a piece of the body listed in $id_search, the second does not. Press the two buttons: the site search, the one in the top bar, finds the first word on this page and knows nothing about the second.

Piece listed in $id_search

This box sits in $body[2], which the page lists among the pieces to search. Its marker word is zampillorio.

Piece outside $id_search

This box sits in $body[3], which the page does not list. Its marker word is brugnafolo.

Alphabets and multibyte characters

The search counts characters, not bytes, and all the site's text is UTF-8 in NFC form: it works with any alphabet. The marker words of this box are in Greek, ζαμπιλλόριο, in Cyrillic, зампиллорио, in Arabic, زامبيلوريو, and in Japanese, ざんぴろりお.

Error handling

An error reaches the user in a dialog, with a code that identifies it in the source (COD. …) and a text; the technical detail, that is the query, the PHP message, file and line, or the gateway's exception, is shown only to the administrator (profile 1), everyone else sees the code alone. No path returns Apache's HTML error page inside a response: the Python gateway too answers in JSON, with err and txt, and the text is translated with the site's dictionary. The buttons raise an error on each of the paths a request can take.

  • The page asks the server for a list of three values and receives a string: gest_result checks the shape of every response before using it, and stops.
  • A branch of the top- file runs a query on a table that does not exist: error_alert answers in JSON with the code COD. HF-01, and the detail to profile 1 only.
  • The same request, sent without the session token: the server rejects it with a 403 before it reaches the page, as it would with a request started from another site.
  • The Python module that computes the hypotenuse receives a negative cathetus and answers {"error": 1, "message": …}: an expected error is data like any other, and the page shows it.
  • The gateway answers 403 with {"err": "FORBIDDEN", "txt": …}, before importing anything; the 500 of a module that raises an exception has the same shape, with the traceback in the server log.
  • The HTTP error pages (400, 403, 404, 413, 500 and 503) are standalone pages of the site, in its language: the 404 goes back to the home after six seconds, and the .json descriptors of the pages are denied by the server to everyone.

Keywords: PortLAB, CMS, PHP framework, scientific portals, multilanguage, PostgreSQL, CNR-IFAC

Moreno Comelli, CNR-IFAC, 2022-2026

  • Creative Commons License Website content: CC BY 4.0, except where otherwise noted

Code & Design by CNR-IFAC - Core by PortLab