Bug in NginxHttpFcgiModule's fastcgi_split_path_info function?

While using Ubuntu 10.10+Nginx 0.8.53+gnosek’s fcgiwrap to serve a
Mailman mailing list server
http://www.gnu.org/software/mailman/index.html, that was installed as
stated in http://wiki.nginx.org/Mailman, I keep getting the error:

[error] FastCGI sent in stderr: “Cannot get script name, is
DOCUMENT_ROOT and SCRIPT_NAME set and is the script executable?”

These attempts were successful:
http://mail.example.com/ => shows standard Mailman Welcome page,
browser bar shows: http://mail.example.com/mailman/listinfo
http://mail.example.com/listinfo => shows standard Mailman Welcome
page, this time browser bar shows: http://mail.example.com/listinfo
http://mail.example.com/admin => shows standard Mailman Admin Links
page, browser bar shows: http://mail.example.com/admin
http://mail.example.com/images/mailman/ => shows “403 Forbidden”
page, as expected http://mail.example.com/pipermail/ => shows “Index
of /pipermail/” page, as expected
http://mail.example.com/mailman/private => shows “You must specify a
list.”, as expected

All other attempts were unsuccessful, such as:
Clicking in “the mailing list overview page” link
http://mail.example.com/cgi-bin/mailman/listinfo or on the “List”
“Mailman” link,

Those only output a “403” (produced by fcgiwrap?)

And the nginx error log shows:
[error] 1181#0: *17 FastCGI sent in
stderr: “Cannot get script name, is DOCUMENT_ROOT and SCRIPT_NAME
set and is the script executable?” while reading response header
from upstream, client: 127.0.1.1,
server: mail.example.com,
request: “GET /cgi-bin/mailman/listinfo HTTP/1.1”,
upstream: “fastcgi://unix:/var/run/fcgiwrap.socket:”,
host: “mail.example.com”,
referrer: “http://mail.example.com/admin

My nginx file has:
server {
listen 80;
server_name mail.example.com;
root /usr/lib/cgi-bin;
location = / {
rewrite ^ /mailman/listinfo permanent;
}
location / {
rewrite ^ /mailman$uri;
}
location /mailman/ {
fastcgi_split_path_info (^/mailman/[^/])(.)$;
#include /etc/nginx/fastcgi_params;
include fastcgi_params;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED
$document_root$fastcgi_path_info; fastcgi_pass
unix:/var/run/fcgiwrap.socket;
}
location /images/mailman {
alias /var/lib/mailman/icons;
}
location /pipermail {
alias /var/lib/mailman/archives/public;
autoindex on;
}
}

My, default and unchanged, /etc/mailman/mm_cfg.py, that has:
DEFAULT_URL_PATTERN = ‘http://%s/cgi-bin/mailman/’
PRIVATE_ARCHIVE_URL = ‘/cgi-bin/mailman/private’
DEFAULT_EMAIL_HOST = ‘mail.example.com
DEFAULT_URL_HOST = ‘mail.example.com

My nginx -V
nginx version: nginx/0.8.53
TLS SNI support enabled
configure arguments: --conf-path=/etc/nginx/nginx.conf
–error-log-path=/var/log/nginx/error.log
–http-client-body-temp-path=/var/lib/nginx/body
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi
–http-log-path=/var/log/nginx/access.log
–http-proxy-temp-path=/var/lib/nginx/proxy
–lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid
–with-http_ssl_module --without-http_limit_req_module
–without-mail_pop3_module --without-mail_smtp_module
–without-mail_imap_module --without-http_uwsgi_module
–without-http_scgi_module --without-http-cache

My cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.1.1 mail.example.com mail
127.1.1.1 www.example.com example.com

On Wed, Nov 10, 2010 at 11:03:01AM +0000, Mark A. wrote:

Hi there,

While using Ubuntu 10.10+Nginx 0.8.53+gnosek’s fcgiwrap to serve a
Mailman mailing list server
http://www.gnu.org/software/mailman/index.html, that was installed as
stated in http://wiki.nginx.org/Mailman, I keep getting the error:

[error] FastCGI sent in stderr: “Cannot get script name, is
DOCUMENT_ROOT and SCRIPT_NAME set and is the script executable?”

At first glance, it looks to me as if nginx is doing exactly what you
told it to. I suspect that a small reconfiguration of mailman will work
for you.

These attempts were successful:
http://mail.example.com/ => shows standard Mailman Welcome page,
browser bar shows: http://mail.example.com/mailman/listinfo

The configuration shows that “/” is (externally) rewritten to
/mailman/listinfo, which is why that appears in the browser bar.

The browser then makes a fresh request for /mailman/listinfo, which is
handled by your location /mailman/ {} block, where
fastcgi_split_path_info
sets $fastcgi_script_name to “/mailman/listinfo”, and $fastcgi_path_info
to
“”, and things work. Presumably the fastcgi server is able to process
the file /usr/lib/cgi-bin/mailman/listinfo.

http://mail.example.com/listinfo => shows standard Mailman Welcome
page, this time browser bar shows: http://mail.example.com/listinfo

Here, /listinfo is handled by the location / {} block, which does a
rewrite (internally) to /mailman/listinfo, which is handled the same as
in the previous case, and things work.

http://mail.example.com/admin => shows standard Mailman Admin Links
page, browser bar shows: http://mail.example.com/admin

Analogous to /listinfo, internal rewrite to /mailman/admin,
$fastcgi_script_name is “/mailman/admin”, $fastcgi_path_info is “”,
things work.

http://mail.example.com/images/mailman/ => shows “403 Forbidden”
page, as expected http://mail.example.com/pipermail/ => shows “Index
of /pipermail/” page, as expected
http://mail.example.com/mailman/private => shows “You must specify a
list.”, as expected

The first two have separate location blocks; the third is similar to
the redirected initial request above.

All other attempts were unsuccessful, such as:
Clicking in “the mailing list overview page” link
http://mail.example.com/cgi-bin/mailman/listinfo or on the “List”
“Mailman” link,

Same as /listinfo case, handled by the location / {} block, internal
rewrite to /mailman/cgi-bin/mailman/listinfo, $fastcgi_script_name is
“/mailman/cgi-bin”, $fastcgi_path_info is “/mailman/listinfo”, and
things don’t work on the fastcgi server because it can’t find the file
to process. There probably is no file /usr/lib/cgi-bin/mailman/cgi-bin.

To make things work for you, you could probably try a new “location
/cgi-bin/ {}” block which rewrites to the same url without the
“/cgi-bin”
at the start.

But it seems more sensible to just…

My, default and unchanged, /etc/mailman/mm_cfg.py, that has:
DEFAULT_URL_PATTERN = ‘http://%s/cgi-bin/mailman/’
PRIVATE_ARCHIVE_URL = ‘/cgi-bin/mailman/private’
DEFAULT_EMAIL_HOST = ‘mail.example.com
DEFAULT_URL_HOST = ‘mail.example.com

…remove the string “/cgi-bin” from two lines up there. (And you could
probably even remove the “/mailman” too.) Your nginx is not configured
to serve from the /cgi-bin urls, but is from the others.

(Note: I haven’t tested any of this.)

The page Mailman | NGINX suggests to configure mailman by
following a separate website. Possibly the information has gotten out
of sync.

Good luck with it,

f

Francis D. [email protected]