Nginx 502 Bad Gateway: It just won't stop

Posted by David on Server Fault See other posts from Server Fault or by David
Published on 2012-10-02T00:04:41Z Indexed on 2012/10/17 17:05 UTC
Read the original article Hit count: 229

Filed under:

I have the same problem that most people seem to have with Nginx: 502 bad gateway errors. They are intermittent but typically happen more than once per session, which means my users are probably running into it nearly every time they use the app. I've tried adjusting fastcgi_buffers and fastcgi_buffer_size (in both directions) to no avail. I've tried various other things with the configuration file but nothing seems to work. Here's my config (note that I've stripped away most of the things I've tried, since they didn't work and I didn't want to bloat the file with a bunch of un-related directives):

server {
    root    /usr/share/nginx/www/;
    index   index.php;

    # Make site accessible from http://localhost/
    server_name localhost;

    # Pass PHP scripts to PHP-FPM
    location ~ \.php {
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
    }

    # Lock the site
    location / {
            auth_basic "Administrator Login";
            auth_basic_user_file /usr/share/nginx/.htpasswd;
    }
    # Hide the password file
    location ~ /\. {
            deny all;
    }

    client_max_body_size 8M;
}

I'm running a small Rackspace cloud server, which should be plenty for handling an app with a small user base...

© Server Fault or respective owner

Related posts about nginx