Tampa
Tampa

Reputation: 78244

How to use sockets with nginx and fastcgi

I am trying to use sockets rather than tcp for nginx and fastcgi.

Below is my config for nginx. It works if I use 127.0.0.1:9001 i.e. tcp connection.

Here is the error log.

2012/03/06 22:04:53 [crit] 19328#0: *1 connect() to unix:/tmp/nginx9001.socket failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: 127.0.0.1, request: "GET /pixel/ HTTP/1.1", upstream: "fastcgi://unix:/tmp/nginx9001.socket:", host: "127.0.0.1"

The nginx conf:

location /pixel/ {
            fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param QUERY_STRING $query_string;
            fastcgi_param CONTENT_TYPE $content_type;
            fastcgi_param CONTENT_LENGTH $content_length;
            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 SERVER_PROTOCOL $server_protocol;
            fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            #fastcgi_pass 127.0.0.1:9001;
                    fastcgi_pass unix:/tmp/nginx9001.socket;
        }

Here is my spawn-fcgi script

exec spawn-fcgi -n -d /home/ubuntu/workspace/rtbopsConfig/rtbServers/ -s /tmp/nginx9001.socket -f /home/ubuntu/workspace/rtbopsConfig/rtbServers/index.py >> /var/log/test.sys.log 2>&1

Upvotes: 1

Views: 11210

Answers (1)

MTeck
MTeck

Reputation: 1688

PHP isn't configured to listen on the unix socket, it's configured to listen on the tcp socket. Change your PHP config to match what you you want it to be.

Upvotes: 3

Related Questions