Press "Enter" to skip to content

Month: August 2019

qmailadmin on nginx

Hi there! After many tests I managed to run qmailadmin under nginx. I leave here the virtualhost configuration file as a reminder in case it is useful to someone in order to avoid installing apache if you do not need it.

The virtualhost works with nginx 1.14.2 and qmailadmin 1.2.16 compiled with the following options/paths:

./configure \
  --enable-htmldir=/usr/local/www/htdocs/qmail \
  --enable-cgibindir=/usr/local/www/htdocs/qmail/cgi-bin \
  --enable-cgipath=/cgi-bin/qmailadmin \
  --enable-imagedir=/usr/local/www/htdocs/qmail/qmailadmin/qmailadmin_img \
  --enable-imageurl=/qmailadmin_img \
  --enable-htmllibdir=/usr/local/www/htdocs/qmail/qmailadmin \
  --enable-qmaildir=/var/qmail \
  --enable-domain-autofill \
  --enable-vpopuser=vpopmail \
  --enable-vpopgroup=vchkpw \
  --enable-autoresponder-path=/usr/local/bin \
  --enable-ezmlmdir=/usr/local/bin/ezmlm \
  --enable-modify-quota \
  --disable-ezmlm-mysql \
  --disable-trivial-password

extracted from here, part of the fantastic qmail notes from Roberto Puzzanghera.

server {
  listen 80 default_server;
  server_name example.tld;

  root  /usr/local/www/htdocs/qmail;

  location /cgi-bin { 
  gzip off;

  # Fastcgi socket
  fastcgi_pass  unix:/var/run/fcgiwrap.socket;

  # Fastcgi parameters, include the standard ones
  include /etc/nginx/fastcgi_params;

  # Adjust non standard parameters (SCRIPT_FILENAME)
  
  fastcgi_split_path_info (^/cgi-bin/qmailadmin[^/]*)(.*)$;
  fastcgi_param SCRIPT_FILENAME  /usr/local/www/htdocs/qmail/cgi-bin/qmailadmin;
  fastcgi_param PATH_INFO $fastcgi_path_info;

  }

  location @rewrite {
    rewrite ^ /cgi-bin/qmailadmin permanent;
  }

  location / {
    try_files $uri @rewrite;
  }

  location /qmailadmin_img/ {
    root  /usr/local/www/htdocs/qmail/qmailadmin;
  }
}

It uses fcgiwrap to execute the qmailadmin cgi script under nginx. Probably this can be better tuned, but works for me and hope that for you too, adapt it to your needs. Comments are welcomed.

Leave a Comment