I'm currently testing a perl cgi application in nginx and fcgiwrap. It's partially working. However I'm having issues getting errors back in the response.
All requests return 200. If the cgi errors, it just returns blank content.
I'm running both nginx and fcgiwrap from supervisord.
This is my supervisord.conf file...
[supervisord]
logfile=/tmp/supervisord.log
nodaemon=true
[fcgi-program:fcgiwrap]
command = /usr/sbin/fcgiwrap
user = www-data
socket = unix:///var/run/supervisor/%(program_name)s.sock
socket_owner = www-data:www-data
socket_mode = 0770
autorestart=true
autostart=true
startsecs=1
startretries=3
stopsignal=QUIT
stopwaitsecs=10
environment=PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin'
redirect_stderr=false
stdout_logfile=/var/log/fcgiwrap_out.log
stderr_logfile=/var/log/fcgiwrap_err.log
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
I get the errors appearing in /var/log/fcgiwrap_err.log. However the error message, and more importantly the status, aren't returned to nginx.
This is my nginx config...
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/web;
index index.html index.cgi;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.cgi$ {
gzip off;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/supervisor/fcgiwrap.sock;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME /var/www/web$fastcgi_script_name;
}
# deny access to .htaccess files
location ~ /\.ht {
deny all;
}
}
I'm not sure whether the issue is due to a misconfiguration of fcgiwrap, nginx, or supervisord.
You said to supervisord to monitor a socket (/var/run/supervisor/fcgiwrap.sock
) but didn't say to fcgiwrap to use that socket.
So PHP connection through this empty socket will never reach fcgiwrap process, and hence you have no error message from fcgiwrap.
You need to change the fcgiwrap command to specify the socket, using -s parameter.