0

I am recieving a 502 Bad gateway error with this config file for my ubuntu nginx server, can anyone see any faults with this? Quite new to Linux so any advise would be helpful. I am trying to get up and running with Learning Locker, but hitting problems with this section.

# Default server configuration
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_serve
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    # Useful logs for debug.
    access_log /var/www/learninglocker/access.log;
    error_log /var/www/learninglocker/error.log;
    rewrite_log on;

    # The location of our projects public directory.
    root /var/www/learninglocker/public;

    # Point index to the Laravel front controller.
    index index.php;

    server_name _;

    location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.php?$query_string;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
    }
    # Remove trailing slash to please routing system.
    if (!-d $request_filename) {
    rewrite ^/(.+)/$ /$1 permanent;
    }

    # PHP FPM configuration.
    location ~* \.php$ {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    # We don't need .ht files with nginx.
    location ~ /\.ht {
    deny all;
    }

    # Set header expirations on per-project basis
    location ~* \.(?:ico|css|js|jpe?g|JPG|png|svg|woff)$ {
    expires 365d;

    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #       include snippets/fastcgi-php.conf;
    #
    #       # With php5-cgi alone:
    #       fastcgi_pass 127.0.0.1:9000;
    #       # With php5-fpm:
    #       fastcgi_pass unix:/var/run/php5-fpm.sock;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #       deny all;
    #}

}

The error log states this: -

2015/05/27 11:20:53 [error] 23518#0: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 11.11.23.23, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "learninglocker.sourcecodingltd.co.uk"

  • 1
    What does /var/www/learninglocker/error.log say? Please edit your question with that info. – Halfgaar May 27 '15 at 10:18
  • 502 error means that there is some error from upstream side. Check logs of php-fpm – Navern May 27 '15 at 12:02

Your Answer

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

Browse other questions tagged or ask your own question.