nginx + spawn-fcgi is serving raw cgi (binary) file content (not executing them) -
i'm stumped trying figure out why nginx + spawn-fastcgi serving raw binary content instead of executing them , serving result.
the goal configure nagios core 4.x using nginx. there many great blogs on this; none have shed light on problem.
i'm using centos 6.6 nginx v1.0.15, spawn-fcgi v1.6.3, , php (php-fpm) v5.4.30.
the php file hosting works great (php-fpm), **it's spawn-fcgi content i'm having issue charge of serving /cgi-bin/*.cgi files. here spwn-fcgi environment:
cat << _eof > /etc/sysconfig/spawn-fcgi options="-u apache -g apache -a 127.0.0.1 -p 9001 -c 32 -f 1 -p /var/run/spawn-fcgi.pid -- /usr/bin/php-cgi" _eof my nginx configuration:
server { listen 80; server_name monitor.mydomain.com; return 301 https://$server_name$request_uri; } server { listen 443; # satisfy allows bypass authentication # allowed ip addresses satisfy any; # local traffic allow 192.168.0.0/24; allow 127.0.0.0/8; # drop rest of world deny all; server_name monitor.mydomain.com; root /usr/share/nagios; ssl_session_timeout 5m; ssl_protocols tlsv1 tlsv1.1 tlsv1.2; ssl_ciphers 'ecdhe-rsa-aes128-gcm-sha256:ecdhe-ecdsa-aes128-gcm-sha256:ecdhe-rsa-aes256-gcm-sha384:ecdhe-ecdsa-aes256-gcm-sha384:dhe-rsa-aes128-gcm-sha256:dhe-dss-aes128-gcm-sha256:kedh+aesgcm:ecdhe-rsa-aes128-sha256:ecdhe-ecdsa-aes128-sha256:ecdhe-rsa-aes128-sha:ecdhe-ecdsa-aes128-sha:ecdhe-rsa-aes256-sha384:ecdhe-ecdsa-aes256-sha384:ecdhe-rsa-aes256-sha:ecdhe-ecdsa-aes256-sha:dhe-rsa-aes128-sha256:dhe-rsa-aes128-sha:dhe-dss-aes128-sha256:dhe-rsa-aes256-sha256:dhe-dss-aes256-sha:dhe-rsa-aes256-sha:aes128-gcm-sha256:aes256-gcm-sha384:aes128:aes256:aes:des-cbc3-sha:high:!anull:!enull:!export:!des:!rc4:!md5:!psk'; ssl_prefer_server_ciphers on; ssl_session_cache builtin:1000 shared:ssl:10m; ssl on; ssl_certificate /etc/pki/tls/certs/mydomain.com.crt; ssl_certificate_key /etc/pki/tls/private/mydomain.com.key; index index.php index.html index.htm; access_log /var/log/nginx/nagios.access.log; error_log /var/log/nginx/nagios.error.log; # security auth_basic "restricted area"; auth_basic_user_file mynagios.htpasswd; location ~ \.htaccess { deny all; } location / { if ($uri ~* "\.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$") { expires max; break; } } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } # redirect server error pages static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass php scripts fastcgi server listening on 127.0.0.1:9000 # location ~ \.php$ { try_files $uri = 404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; } #location ~ \.cgi$ { location /nagios/cgi-bin/ { root /usr/lib64/nagios/cgi; rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break; fastcgi_param auth_user $remote_user; fastcgi_param remote_user $remote_user; fastcgi_param script_filename $document_root$fastcgi_script_name; #fastcgi_pass unix:/var/run/php-fcgi.sock; fastcgi_pass 127.0.0.1:9001; include fastcgi_params; } } the tool in question running:
[root@fserver conf.d]# netstat -pnat | egrep '900(0|1)' tcp 0 0 127.0.0.1:9000 0.0.0.0:* listen 9054/php-fpm tcp 0 0 127.0.0.1:9001 0.0.0.0:* listen 28888/php-cgi again, in nutshell; config 'almost' working well, request https://monitor.mydomain.com/nagios/cgi-bin/status.cgi servers content:
elf>... <raw ugly content> it's worth noting was using selinux (wrote own module nagios), have disabled (all of selinux) until can resolved cgi issue.
any advice guys can provide fantastic! tia
i figured issue out; should have same problem did, result of not using fcgiwrap. followed instructions , compiled it.
using fcgiwrap allowed me execute code spawn-fcgi returned instead of displaying raw data (my problem):
cat << _eof > /etc/sysconfig/spawn-fcgi options="-u apache -g apache -a 127.0.0.1 -p 9001 -f /usr/sbin/fcgiwrap -p /var/run/spawn-fcgi.pid" _eof # restart spawn-fcgi service spawn-fcgi restart
Comments
Post a Comment