nginx/fastcgi/fcgiwrap

Moderator: crythias

Locked
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

nginx/fastcgi/fcgiwrap

Post by crythias »

Most of what you find on the internet works.
If you get
An error occurred while reading CGI reply (no response received)
you'll need to make sure to install the perl FCGI module (yes, even if you've otrs.CheckModules.pl and everything is good)
(How did you figure this out?)
perl -cw /opt/otrs/bin/fcgi-bin/installer.pl

You *don't* have to spawn if you don't want to... you can use fcgiwrap's default install's socket.


nginx otrs.conf example:

Code: Select all

server {
  listen 80;
  server_name _;
  root /opt/otrs/bin/fcgi-bin;
  index index.html;
  location /otrs-web {
    gzip on;
    alias /opt/otrs/var/httpd/htdocs;
  }
  location ~ ^/otrs/(.*\.pl)(/.*)?$ {
    gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.pl;
fastcgi_param SCRIPT_FILENAME   /opt/otrs/bin/fcgi-bin/$1;
fastcgi_param QUERY_STRING      $query_string;
fastcgi_param REQUEST_METHOD    $request_method;
fastcgi_param CONTENT_TYPE      $content_type;
fastcgi_param CONTENT_LENGTH    $content_length;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE   nginx;
fastcgi_param SCRIPT_NAME       $fastcgi_script_name;
fastcgi_param REQUEST_URI       $request_uri;
fastcgi_param DOCUMENT_URI      $document_uri;
fastcgi_param DOCUMENT_ROOT     $document_root;
fastcgi_param SERVER_PROTOCOL   $server_protocol;
fastcgi_param REMOTE_ADDR       $remote_addr;
fastcgi_param REMOTE_PORT       $remote_port;
fastcgi_param SERVER_ADDR       $server_addr;
fastcgi_param SERVER_PORT       $server_port;
fastcgi_param SERVER_NAME       $server_name;
}
}
Bad Gateway is a host of issues, but one troubleshooting method is to look at /var/log/nginx/error.log. If a particular module is causing issues, you will want to see if there are any notifications that the module can't be called for some reason.

connect() to unix:/var/run/fcgiwrap.socket failed (111: Connection refused) while connecting to upstream, client: ipaddress, server: , request: "GET /otrs/installer.pl HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "ipaddress"

This error means (more or less) that even if the file exists, it's not acting as a socket and refusing connections. (fcgiwrap isn't running on that socket file).

connect() to unix:/var/run/otrs/fcgiwrap.socket failed (13: Permission denied) while connecting to upstream, client: ipaddress, server: , request: "GET /otrs/installer.pl HTTP/1.1", upstream: "fastcgi://unix:/var/run/otrs/fcgiwrap.socket:", host: "ipaddress"

This error means that the socket file is not running under the permissions of the web server user (www/www-data). If you create your own socket file or location with root, make sure you chown it to the web user.

I don't know much about nginx. I'm not an expert. I just thought I'd give some feedback from my first installation ever this weekend.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
klausneil
Znuny superhero
Posts: 682
Joined: 29 May 2012, 22:47
Znuny Version: 6.0.24
Real Name: Klaus Salazar
Location: Perú

Re: nginx/fastcgi/fcgiwrap

Post by klausneil »

Hi, I'm following the steps but I get the following message, i'm installing the version 3.2.x with nginx

root@otrs:/opt# perl -cw /opt/otrs/bin/fcgi-bin/installer.pl
Can't locate FCGI.pm in @INC (@INC contains: /opt/otrs/bin/fcgi-bin/../../Custom /opt/otrs/bin/fcgi-bin/../../Kernel/cpan-lib /opt/otrs/bin/fcgi-bin/../.. /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at /opt/otrs/bin/fcgi-bin/../../Kernel/cpan-lib/CGI/Fast.pm line 25.
BEGIN failed--compilation aborted at /opt/otrs/bin/fcgi-bin/../../Kernel/cpan-lib/CGI/Fast.pm line 25.
Compilation failed in require at /opt/otrs/bin/fcgi-bin/installer.pl line 32.
BEGIN failed--compilation aborted at /opt/otrs/bin/fcgi-bin/installer.pl line 32.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: nginx/fastcgi/fcgiwrap

Post by crythias »

crythias wrote:you'll need to make sure to install the perl FCGI module
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
klausneil
Znuny superhero
Posts: 682
Joined: 29 May 2012, 22:47
Znuny Version: 6.0.24
Real Name: Klaus Salazar
Location: Perú

Re: nginx/fastcgi/fcgiwrap

Post by klausneil »

perfect..
bacanol
Znuny newbie
Posts: 5
Joined: 03 Nov 2011, 09:51
Znuny Version: 3.3.6

Re: nginx/fastcgi/fcgiwrap

Post by bacanol »

Hello!

I get exactly this "An error occurred while reading CGI reply (no response received)" and I performed all steps above. I do not get any perl errors on command line. Is there a way to make errors for fcgiwrap visible or to investigate the error? I am using FreeBSD 9.2 with nginx 1.4.4, fcgiwrap from ports tree. I do not see any errors in the current log files.

Any idea?
OTRS 3.3.6 on FreeBSD 10 with MariaDB and nginx
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: nginx/fastcgi/fcgiwrap

Post by crythias »

@bacanol, how would I begin to replicate your experience?
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
bacanol
Znuny newbie
Posts: 5
Joined: 03 Nov 2011, 09:51
Znuny Version: 3.3.6

Re: nginx/fastcgi/fcgiwrap

Post by bacanol »

Sorry, I was in a hurry and did not supply the necessary informaion. My experience so far is as follows:
- I am running a FreeBSD jail with 9.2 FreeBSD version
- I am using nginx with version 1.4.4
- I managed to install OTRS 3.3.4 into /opt/otrs
- I use fcgiwrap with sockets on the same jail

Durrently I get another error 502 Bad Gateway, but nothing is showing up in the nginx logs anymore. I have no idea how to verbose log fcgiwrap? I guess it is the source of my issue right now.

Here is the socket listing for fcgiwrap:

Code: Select all

ls -lart /var/run/fcgiwrap/fcgiwrap.*
srwxr-xr-x  1 www  www  0 Feb 24 10:33 /var/run/fcgiwrap/fcgiwrap.sock
Here you see my conf for the otrs part within nginx:

Code: Select all

cat /www/vhosts/config/otrs
server {
    server_name  otrs.bacanol.com; # IP or ServerName
        access_log /www/vhosts/piwik/.log/nginx.access.log main;
          error_log /var/log/nginx-error.log debug;

    # These 2 lines were necessary to prevent buffer problems in OTRS
   fastcgi_buffers 8 16k;
   fastcgi_buffer_size 32k;

    # Enter your htdocs path here, e.g. /opt/otrs/var/httpd/htdocs
    root /opt/otrs/var/httpd/htdocs/;

    # Do not log favicon access
    location = /favicon.ico {
        access_log     off;
        log_not_found  off;
    }

    location /otrs-web/ {
         alias /opt/otrs/var/httpd/htdocs/;
    }

    location ~ ^/otrs/(.*\.pl)(/.*)?$ {
        gzip off;
        # Enter your fcgiwrap socket here
        fastcgi_pass  unix:/var/run/fcgiwrap/fcgiwrap.sock;
        fastcgi_index index.pl;
        # Enter your OTRS cgi-bin path, e.g. /opt/otrs/bin/cgi-bin
        fastcgi_param  SCRIPT_FILENAME /opt/otrs/bin/cgi-bin/$1;
        include fastcgi_params;
    }
}
Here is my fastcgi_parms:

Code: Select all

cat /usr/local/etc/nginx/fastcgi_params
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

fastcgi_param HTTPS $https;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
Here are the version numbers for the versions in use:

Code: Select all

nginx -v
nginx version: nginx/1.4.4
fcgiwrap -h
fcgiwrap version 1.1.0

Do you have any idea how to proceed?

Thank you and best regards,

bacanol
OTRS 3.3.6 on FreeBSD 10 with MariaDB and nginx
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: nginx/fastcgi/fcgiwrap

Post by crythias »

You didn't show the version of your perl FCGI module.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
bacanol
Znuny newbie
Posts: 5
Joined: 03 Nov 2011, 09:51
Znuny Version: 3.3.6

Re: nginx/fastcgi/fcgiwrap

Post by bacanol »

Hi,

So I upgraded recently to FreeBSD 10 and these are the new versions:

Code: Select all

 pkg info fcgiwrap
fcgiwrap-1.1.0
Name           : fcgiwrap
Version        : 1.1.0
Installed on   : Fri Feb 28 20:34:33 UTC 2014
Origin         : www/fcgiwrap
Architecture   : freebsd:9:x86:64
Prefix         : /usr/local
Maintainer     : unknown
WWW            : http://nginx.localdomain.pl/wiki/FcgiWrap
Comment        : Simple FastCGI wrapper for CGI scripts
Shared Libs required:
        libfcgi.so.0
Flat size      : 26.7KiB
Description    :
fcgiwrap is a simple server for running CGI applications over FastCGI. It hopes
to provide clean CGI support to Nginx (and other web servers that may need it).

Features:
    * very lightweight (84KB of private memory per instance)
    * fixes broken CR/LF in headers
    * handles environment in a sane way (CGI scripts get HTTP-related env. vars
    * from FastCGI parameters and inherit all the others from fcgiwrap's
    * environment)
    * no configuration, so you can run several sites off the same fcgiwrap pool
    * passes CGI stderr output to fcgiwrap's stderr (this is by design but
    * stderr could be also passed to FastCGI stderr stream)

WWW: http://nginx.localdomain.pl/wiki/FcgiWrap

Code: Select all

pkg info perl5.18
perl5.18-5.18.2_1
Name           : perl5.18
Version        : 5.18.2_1
Installed on   : Sun Mar 16 10:33:26 UTC 2014
Origin         : lang/perl5.18
Architecture   : freebsd:10:x86:64
Prefix         : /usr/local
Categories     : perl5 lang devel
Licenses       : GPLv1 or ART10
Maintainer     : perl@FreeBSD.org
WWW            : http://www.perl.org/
Comment        : Practical Extraction and Report Language
Options        :
        DEBUG          : off
        GDBM           : off
        MULTIPLICITY   : off
        PERL_64BITINT  : on
        PERL_MALLOC    : off
        PTHREAD        : on
        SITECUSTOMIZE  : off
        THREADS        : on
        USE_PERL       : on
Shared Libs required:
        libperl.so
Flat size      : 48.2MiB
Description    :
Perl is a language that combines some of the features of C, sed, awk and
shell.  See the manual page for more hype.  There are also many books
published by O'Reilly & Assoc.  See pod/perlbook.pod for more
information.

WWW: http://www.perl.org/

Code: Select all

nginx-1.4.6,1
Name           : nginx
Version        : 1.4.6,1
Installed on   : Mon Mar 17 18:25:51 UTC 2014
Origin         : www/nginx
Architecture   : freebsd:10:x86:64
Prefix         : /usr/local
Categories     : www perl5 ipv6
Licenses       : BSD
Maintainer     : osa@FreeBSD.org
WWW            : http://nginx.org/
Comment        : Robust and small WWW server
Options        :
	ARRAYVAR       : off
	CACHE_PURGE    : on
	CTPP2          : off
	DEBUG          : off
	DEBUGLOG       : off
	DRIZZLE        : off
	ECHO           : off
	ENCRYPTSESSION : off
	FILE_AIO       : on
	FORMINPUT      : off
	GOOGLE_PERFTOOLS: off
	GRIDFS         : off
	HEADERS_MORE   : off
	HTTP           : on
	HTTP_ACCEPT_LANGUAGE: off
	HTTP_ACCESSKEY : off
	HTTP_ADDITION  : off
	HTTP_AUTH_DIGEST: off
	HTTP_AUTH_LDAP : off
	HTTP_AUTH_PAM  : off
	HTTP_AUTH_REQ  : off
	HTTP_CACHE     : on
	HTTP_DAV       : off
	HTTP_DAV_EXT   : off
	HTTP_EVAL      : off
	HTTP_FANCYINDEX: off
	HTTP_FLV       : off
	HTTP_FOOTER    : off
	HTTP_GEOIP     : on
	HTTP_GUNZIP_FILTER: on
	HTTP_GZIP_STATIC: on
	HTTP_IMAGE_FILTER: off
	HTTP_MOGILEFS  : off
	HTTP_MP4       : off
	HTTP_MP4_H264  : off
	HTTP_NOTICE    : off
	HTTP_PERL      : on
	HTTP_PUSH      : off
	HTTP_PUSH_STREAM: off
	HTTP_RANDOM_INDEX: off
	HTTP_REALIP    : on
	HTTP_REDIS     : off
	HTTP_RESPONSE  : off
	HTTP_REWRITE   : on
	HTTP_SECURE_LINK: off
	HTTP_SSL       : on
	HTTP_STATUS    : off
	HTTP_SUB       : off
	HTTP_SUBS_FILTER: off
	HTTP_UPLOAD    : off
	HTTP_UPLOAD_PROGRESS: off
	HTTP_UPSTREAM_FAIR: off
	HTTP_UPSTREAM_HASH: off
	HTTP_UPSTREAM_STICKY: off
	HTTP_XSLT      : off
	HTTP_ZIP       : on
	ICONV          : off
	IPV6           : on
	LET            : off
	LUA            : off
	MAIL           : off
	MAIL_IMAP      : off
	MAIL_POP3      : off
	MAIL_SMTP      : off
	MAIL_SSL       : off
	MEMC           : off
	MODSECURITY    : off
	NAXSI          : on
	PASSENGER      : off
	POSTGRES       : off
	RDS_CSV        : off
	RDS_JSON       : off
	REDIS2         : off
	RTMP           : off
	SET_MISC       : off
	SFLOW          : off
	SLOWFS_CACHE   : off
	SPDY           : off
	SRCACHE        : off
	SUPERVISORD    : off
	SYSLOG_SUPPORT : off
	TCP_PROXY      : off
	UDPLOG         : off
	VIDEO          : off
	WWW            : on
	XRID_HEADER    : off
	XSS            : off
Shared Libs required:
	libperl.so
	libpcre.so.3
	libGeoIP.so.5
Flat size      : 788KiB
Description    :
NGINX is a high performance edge web server with the lowest memory footprint
and the key features to build modern and efficient web infrastructure.

NGINX functionality includes HTTP server, HTTP and mail reverse proxy, caching,
load balancing, compression, request throttling, connection multiplexing and
reuse, SSL offload and HTTP media streaming.

WWW: http://nginx.org/
WWW: http://nginx.com/

Code: Select all

OTRS 3.3.6
Best regards,

bacanol
Last edited by bacanol on 02 Apr 2014, 15:21, edited 1 time in total.
OTRS 3.3.6 on FreeBSD 10 with MariaDB and nginx
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: nginx/fastcgi/fcgiwrap

Post by crythias »

ok, so how does that help? Can you confirm the perl FCGI module is installed?
What is your current status of OTRS?
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
bacanol
Znuny newbie
Posts: 5
Joined: 03 Nov 2011, 09:51
Znuny Version: 3.3.6

Re: nginx/fastcgi/fcgiwrap

Post by bacanol »

Hi!

Code: Select all

FCGI is up to date (0.74).
The current state is that I get no error message, but a blank site when I try to access OTRS on FreeBSD10

Best regards,

bacanol
OTRS 3.3.6 on FreeBSD 10 with MariaDB and nginx
boosten
Znuny newbie
Posts: 10
Joined: 24 Mar 2014, 14:50
Znuny Version: 6.1
Real Name: Alexander

Re: nginx/fastcgi/fcgiwrap

Post by boosten »

I think you should point your script to fcgi-bin folder:
fastcgi_param SCRIPT_FILENAME /usr/local/otrs/bin/fcgi-bin/$1;
viniciusferrao
Znuny newbie
Posts: 4
Joined: 05 Jul 2014, 19:33
Znuny Version: 3.3.1
Real Name: Vinícius Ferrão
Company: Universidade Federal do Rio de Janeiro

Re: nginx/fastcgi/fcgiwrap

Post by viniciusferrao »

Any progress with this issue?

I'm not able to setup OTRS with nginx, fcgiwrap and FreeBSD 10.
Locked