Post

Jexus Series: The Configuration System

The Jexus configuration system is more similar to Apache/Nginx, rather than IIS.

Server Configuration

The configuration file, which contains most of Jexus settings, is located in Jexus installation folder (usually /usr/jexus) and named jws.conf.

Unlike IIS which uses XML to store settings, the Jexus settings are stored in key-value pair, for example

1
2
SiteLogDir=log
SiteConfigDir=siteconf

The description of each settings is listed as below,

SettingMandatory?Description
SiteConfigDiryesThe directory that holds web site configuration files. Relative paths to jws.exe can be used.
SiteLogDiryesThe directory that holds the log files. Relative paths to jws.exe can be used.
RuntimenoApplication pool ASP.NET runtime version. For example, Runtime=v4.0.30319
httpd.usernoApplication pool identity. For example, httpd.user=www-data

The first two settings are mandatory.

The log directory must give Jexus process permissions to write, as Jexus server log and web site access logs are all generated and stored there.

In default installation, /usr/jexus/siteconf is used as configuration directory, while /usr/jexus/log is used as log directory.

Web Site Configuration

Jexus supports multiple web sites running on the same server. The web sites use individual bindings to distinguish from each other.

The web site configuration files must be saved in the configuration directory set in jws.conf (aka SiteConfigDir). The configuration file name is used as site name (site name is only used in Jexus commands), which should not contain spaces. Note that all files in configuration directory are treated as web site configuration files. Thus, don’t leave anything else there.

In default installation, a default web site is created. Its configuration file is /usr/jexus/siteconf/default. Just like jws.conf, the web site configuration is also stored in key value pair, and the description of each settings is as below,

SettingMandatory?Description  
portyesThe port number used for this web site. Default is port=80.  
hostsnoThe host header accepted by this web site. Default is hosts=*, which means any host header is accepted. Wildcard is also supported, such as *.mysite.com.  
rootyesThe directory mapping. The default is root=/ /var/www/default, which maps physical directory /var/www/default that contains the web site contents to web site root.  
indexesnoDefault document name list. For example, when indexes=index.aspx,index.htm is used, access to / will be resolved to index.aspx if it exists, and then index.htm if exists, and 404 if none of them exists. When this setting is not set, Jexus uses its built-in name list. See (*1)for more details.  
rewritenoURL rewrite rule. For example, rewrite=^/.+?.(aspphpcgi)$ /404.html means any access to classic ASP/PHP/CGI pages is rewritten to /404.html. To use multiple rules, use multiple lines of rewrite=.
denyfromnoIP address restriction. For example, when denyfrom=111.222.111.*,1.1.1.1 is used, access from the IP addreses are denied. Mask is also supported, such as denyfrom=192.168.1.0/255.255.255.0.  
DenyDirsnoHidden segments. When DenyDirs=bin,App_code is used, access to such URL paths is denied.  
checkquerynoQuery strings restriction. Jexus uses built-in logic to perform query safety check. The default is checkquery=true. Note that by setting this to true, there is some impact on Jexus performance.  
nofilenoNOFILE is a Jexus specific feature. It is similar to IIS custom error pages for 404. When nofile=/mvc/controller.aspx is used, access to non-existent files is redirected to /mvc/controller.aspx. Note that the original URL is passed via X-Real-Uri server variable.  
nolognoLogging flag. The default is nolog=false. When set to true, Jexus stops generating log files for this web site.  
keep_alivenoHTTP keep-alive flag. The default is keep_alive=true.  
reproxynoReverse proxy rule. When reproxy= /abc/ http://www.xxxx.com:890/abc/ is used, requests on /abc/ (source) will be redirected to http://www.xxxx.com:890/abc/ (destination). The destination can be multiple, so that Jexus randomly picks one from them, which is similar to load balancing. For example, reproxy=/abc/ http://192.168.0.3/abc/,http://192.168.0.4/abc/.  
fastcgi.addnoFastCGI rule. For TCP connections, typical setting is fastcgi.add=php,php3tcp:127.0.0.1:9000, which forwards requests of .php or php3 extensions to 127.0.0.1:9000 via TCP. For UNIX sockets, typical setting is fastcgi.add=php,php3socket:/tmp/phpsvrusegzipnoGZip compression flag. The default is usegzip=true.
usehttpsnoSSL flag. To enable HTTPS, this setting must be set to true, and port must be set to 443 at the same time. The default is usehttps=false. See (*2) for more details.  

*1 The Jexus built-in default document name list is as below,

  • index.aspx
  • Index.aspx
  • default.aspx
  • Default.aspx
  • index.htm
  • Index.htm
  • default.htm
  • Default.htm
  • index.html
  • Index.html
  • default.html
  • Default.html
  • index.php
  • Index.php
  • default.php
  • Default.php

*2 To enable HTTPS, please follow the steps in this blog post.

TODO:

© Lex Li. All rights reserved. The code included is licensed under CC BY 4.0 unless otherwise noted.
Advertisement

© - Lex Li. All rights reserved.

Using the Chirpy theme for Jekyll.

Last updated on April 14, 2024