2

My code is based on http://wiki.nginx.org/Drupal and the result is 502 bad gateway. I have tried so many ways but dont work.... how i can solve this? thanks

server {
        listen 8093;
        server_name localhost;
        root /home/ITEP;

        # Enable compression, this will help if you have for instance advagg‎ module
        # by serving Gzip versions of the files.
        #gzip_static on;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        # This matters if you use drush prior to 5.x
        # After 5.x backups are stored outside the Drupal install.
        #location = /backup {
        #        deny all;
        #}

        # Very rarely should these ever be accessed outside of your lan
        location ~* \.(txt|log)$ {
                allow 192.168.0.0/16;
                deny all;
        }

        location ~ \..*/.*\.php$ {
                return 403;
        }

        # No no for private
        location ~ ^/sites/.*/private/ {
                return 403;
        }

        # Block access to "hidden" files and directories whose names begin with a
        # period. This includes directories used by version control systems such
        # as Subversion or Git to store control files.
        location ~ (^|/)\. {
                return 403;
        }

        location / {
                # This is cool because no php is touched for static content
                try_files $uri @rewrite;
        }

        location @rewrite {
                # You have 2 options here
                # For D7 and above:
                # Clean URLs are handled in drupal_environment_initialize().
                rewrite ^ /index.php;
                # For Drupal 6 and bwlow:
                # Some modules enforce no slash (/) at the end of the URL
                # Else this rewrite block wouldn't be needed (GlobalRedirect)
                #rewrite ^/(.*)$ /index.php?q=$1;
        }

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                fastcgi_intercept_errors on;
                fastcgi_pass unix:/tmp/phpfpm.sock;
        }

        # Fighting with Styles? This little gem is amazing.
        # This is for D6
        #location ~ ^/sites/.*/files/imagecache/ {
        # This is for D7 and D8
        location ~ ^/sites/.*/files/styles/ {
                try_files $uri @rewrite;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}

I'm using drupal 7.... fresh install

  • 1
    While this might be Drupal question, I believe you would have better chance for an answer at webmasters.stackexchange.com or serverfault.com (if you can meet their quality requirements, of course), because your problem requires nginx skills, and Drupal on nginx is not common. – Mołot Jul 1 '15 at 9:01
  • It's almost definitely not a Drupal issue, smells like an FPM problem. Check your server logs (web and FPM), they should have more detailed information on what's going on. – Clive Jul 1 '15 at 9:06
1

The location of file phpfpm.sock may vary depending on Operating System:

Try find the phpfpm.sock file on your server: find / -name php*fpm.sock

and then change the following line fastcgi_pass unix:/tmp/phpfpm.sock;

to reference phpfpm.sock from the correct location.

Example (Ubuntu 14): fastcgi_pass unix:/var/run/php5-fpm.sock;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.