NaviServer Programmable Web Server

admin-maintenance(n)

NaviServer Manual – 5.2.0a


[ Main Table Of Contents | Table Of Contents | Keyword Index ]

Name

admin-maintenance - NaviServer Maintenance Guide

Table Of Contents

Description

This guide provides essential information for maintaining and securing NaviServer.

Maintenance Tasks

Regular maintenance is essential for ensuring continuous and reliable service. Key tasks include:

  1. Backing up pages and associated files for each virtual server.

  2. Archiving the access log to preserve historical data.

  3. Backing up the server log, especially when verbose logging is enabled.

  4. Backing up Tcl script directories.

  5. Backing up the bin directory, particularly if custom loadable modules are used.

Detailed instructions for each maintenance task are provided in the following sections.

Maintain the Directories

Regular backups of key NaviServer directories are vital to protect against data loss due to filesystem failures.

Back Up the Pages Directory

The pages directory is defined by the PageDir parameter which defaults to the /pages subdirectory under NaviServer home. When multiple servers are running with the same server configuration, the home directory can be determined dynamically based on the Host: header field mass virtual hosting. Keep this in mind, when performing backups.

Schedule regular backups using your preferred method (e.g., nightly cron jobs).

Notice, that NaviServer provides cron-like service by using ns_schedule to run jobs periodically or at certain times in the background. This can ease maintenance since everything can be done in the same environment.

Back Up the Access Log

The access log, per default located in logs/access.log, should be backed up frequently. Since NaviServer automatically deletes older logs beyond the configured MaxBackup limit, manual backups are required to retain a complete log history. It is recommended to use timestamp based filenames for logfile rolling (using. e.g.. the day in the filename; see ns_accesslog). This has the advantage, that the filenames are stable, such that on a system-wide backup, the old logfilenames are stable and do not required backups, whenever the log files is rolled.

Back Up the Server Log

Regular backups are recommended to preserve this critical information, since the file often reveals intrusion attempts, or provides information, when a certain behavior started, etc. Although the server log generally grows slowly on small sites, verbose logging (e.g., during debugging) can cause rapid expansion, especially when the tracffic is high. For keeping storage requirement low, use a timestamp based filenames for logfile rolling (see ns_log).

Back Up the Tcl Scripts Directory

Back up the Tcl scripts directories, which include both virtual server-specific scripts (typically in the /tcl subdirectory) and global scripts (in /modules/tcl). Also, ensure that any external files referenced by these scripts are included in your backup strategy.

Back Up the bin Directory

The /bin directory contains the NaviServer binary and any dynamically loadable modules. If you maintain custom modules, back up both the binaries and their source code to avoid lengthy recompilations after a failure.

Directory Structure

The following table outlines the primary directories created during NaviServer installation, the types of files they contain, and the configuration parameters that affect them.

/certificates

Default directory for storing certificates in PEM format.

/conf

Directory containing NaviServer configuration files. Although this is the conventional location, configuration files can reside anywhere if the nsd process is provided with an absolute path.

Typical Files:

 .tcl files (e.g., nsd-config.tcl sample-config.tcl openacs-config.tcl}
/bin

Directory containing the NaviServer binary, supplementary binaries, and dynamically loadable C modules.

Typical files:

 nsd, tclsh, critcl, nsproxy-helper, .so files, etc.
/include

Directory containing header files needed for compiling additional C modules.

Typical files:

 .h files
/invalid-certificates

Default directory for storing certificates that fail validation, populated by ns_http. For details, see HTTPS Client Certificate Management.

/lib

Directory containing libraries used to build custom components and support extra installed modules.

Typical files:

 libnsd.so,
 libnsdb.so,
 libnsthread.so,
 libnsproxy.so,
 ...
/logs

Default directory containing log files and the server PID file.

Typical files:

 access.log,
 server.log,
 nsd.pid
/modules

Contains directories for modules that operate across servers (e.g., "tcl", "nsperm").

/modules/nsperm

Directory containing user, group, and permission files used by the nsperm module for authentication and access control.

Typical files:

 passwd, group, hosts.allow, hosts.deny, perms
/modules/tcl

Default directory for the server's private Tcl script library.

Typical files:

 .tcl files
/pages

Default directory where pages and images are stored. Users typically organize content into subdirectories.

Typical files:

 .htm, .html, .shtml, .adp, .png, .css, ...
/tcl

Default directory for the shared Tcl script library, including examples and module-specific scripts. Top-level files in this directory are loaded during startup.

Typical files:

 .tcl files

Security Guide

This section provides guidelines to secure your NaviServer installation and protect sensitive data from unauthorized access. Follow these recommendations to minimize vulnerabilities and safeguard your system.

User and Credential Management

For production applications, use an established system for user and credential management, such as OpenACS. OpenACS supports several password hashing algorithms for local accounts, including Argon2, and offers integrations with PAM, LDAP, and OAuth-based identity providers through optional packages.

The installation examples use nsadmin as the Unix user and group under which NaviServer runs. This operating-system identity is separate from the nsadmin login used by NaviServer modules.

For small installations, the optional nsperm module provides file-based authentication and authorization. The shipped password file, modules/nsperm/passwd relative to the NaviServer home directory, includes this administrator entry:

 nsadmin:ubphBI5lDzSYc:::::

Change the shipped nsadmin password with ns_permpasswd before enabling administrative access. This is the normal way to change a password in nsperm: the command uses ns_crypt internally and updates both the password file and the running server's user record.

When nscp and nsstats are both configured to use the same nsperm account, they authenticate against the same password record, so it only needs to be changed in one place.

If you maintain the nsperm password file by hand, use ns_crypt with a two-character salt to generate a compatible legacy hash. Replace only the password field, then reload the nsperm records with ns_permreload or restart NaviServer. This format is for compatibility with nsperm, not for new applications. See Defining Users.

Password Hashing for Applications and Modules

Applications and modules that manage their own credentials can use NaviServer's ns_crypto commands for password hashing: ns_crypto::argon2, ns_crypto::scrypt, and ns_crypto::pbkdf2_hmac. Availability depends on the OpenSSL version used by the build. These hashes are not interchangeable with entries in the nsperm password file.

Permission Settings

Effective permission management is critical for securing your server. Authentication is only the first step; comprehensive permission settings ensure that users have appropriate access rights. Systems like OpenACS employ dynamic, role-based permission management for files and directories. If you use the nsperm module, you can implement file-level security in ADP pages and set appropriate permission records as follows:

  1. Maintain identical permission records for both GET and POST requests.

  2. Remove permission records for network publishing operations (PUT, DELETE, MKDIR, BROWSE) for all users except nsadmin.

  3. Note that a permission record for a directory typically applies recursively to all its subdirectories.

Define permission entries in the /modules/nsperm/perms file; the default file includes comments explaining the format.

For more details on setting permissions via the nsperm module, see the Permissions section.

Security Recommendations

To further enhance security, consider the following recommendations:

  • Keep NaviServer up to date - use the latest released version.

  • Consider running NaviServer containerized or within a chroot environment.

  • For HTTP client requests (ns_http, ns_connchan), do not disable peer certificate validation; ensure that the trusted root certificates (e.g., CAfile ca-bundle.crt) are current.

  • Check uses of ns/server/$server/fastpath/directorylisting. Directory listings should be enabled only when explicitly intended, since generated listings can cause potential information disclosure when index files are missing. Sites relying on this behavior should set the parameter explicitly to simple or fancy.

  • Regularly review your system log for entries especially with severity Security and any unusual activity.

  • Enable logging for HTTP client and SMTP requests (via the nssmtpd module) when these services are in use.

  • When using the nsperm module, ensure that a secure password is set.

  • When using the nscp module, restrict access to the control port to localhost only (see NaviServer Control Port Guide).

  • When using the nsstats module, particularly with OpenACS, restrict access to secured administration paths or configure nsperm accordingly.

  • Limit the installed modules and packages to those essential for your NaviServer deployment.

  • Monitor resource usage (requests, threads, memory, locks, etc.) using the nsstats module or external tools (e.g., Munin) to detect bottlenecks and ensure availability.

  • For high security web sites, do no reveal the server implementation and the version information. You might deactivate this information per server in the configuration file:

  • To apply temporary firewall bans for known probe requests, see Protecting NaviServer with Fail2Ban.

     ns_section ns/server/$server {
       ...
       #
       # Configuration of HTTP responses
       #
       ns_param noticedetail false		  ;# include server signature in ns_returnnotice commands (errors, redirects, ...)
       ns_param noticeadp    returnnotice.adp ;# ADP file for ns_returnnotice commands (errors, redirects, ...)
       ns_param stealthmode  true             ;# omit "Server:" header field in responses
     }
    
  • Scan you site regularly with Vulnerability Scanning Tools.

Setup chroot Environment

In case you are deciding to stetup a chroot jail, this section provides basic instructions for setting up NaviServer in a chroot environment (sometimes called a chroot jail).

Running NaviServer in a chroot environment confines the server to a specified directory, making all absolute file paths relative to the new root. Although chroot does not secure file content, it effectively limits access to sensitive files (e.g., passwords, configuration files).

Because a chroot jail must be self-contained, you need to copy all necessary programs, device files, and libraries into the new root directory. Example:

 mkdir $root/dev $root/tmp $root/etc
 chmod 1777 $root/tmp
 $root/dev; /dev/MAKEDEV generic usema
 cp /etc/passwd /etc/resolve.conf $root/etc

For Debian/Ubuntu platforms, you can use debootstrap package for setting up the chroot environment.

Once the chroot environment is created, you can run NaviServer with the -r option:

 nsd -t nsd.tcl -r $root

Tcl Commands and Library

Restrict access to Tcl commands and libraries to minimize potential abuse. Although NaviServer runs as a non-privileged user, a compromised account might still execute dangerous Tcl commands. Consider disabling the following if they are not required by your application:

  • File system related functions, such as open, read, and puts

  • The NaviServer ns_sock* Tcl functions

  • The Tcl socket routines

  • The exec command

  • The file command, or at least the delete and rename features

  • The exit command

  • Database access (e.g. via nsdb).

In Tcl, you can completely disable (delete) unsafe commands to prevent unauthorized execution. But deleting is certainly only an option, when these commands are not used by your application.

See Also

admin-install, commandlist, ns_server

Keywords

certificate, chroot, container, nscp, nsd, nsdb, nsperm, password, security