EBs - nginx config in laravel app cannot login.

0

I just deploy a laravel app with auth for login. Everything work ok, however I could not login and show 504 error.

My nginx conf:

user                    nginx;
error_log               /var/log/nginx/error.log warn;
pid                     /var/run/nginx.pid;
worker_processes        auto;
worker_rlimit_nofile    32153;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    include       conf.d/*.conf;

    map $http_upgrade $connection_upgrade {
        default     "upgrade";
    }

    server {
        listen        80 default_server;
        access_log    /var/log/nginx/access.log main;

        client_header_timeout 600s;
        client_body_timeout   600s;
        keepalive_timeout     600s;
        proxy_connect_timeout 600s;
        proxy_send_timeout    600s;
        proxy_read_timeout    600s;
        fastcgi_send_timeout  600s;
        fastcgi_read_timeout  600s;
        gzip                  off;
        gzip_comp_level       4;
        gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        # Do not include the Elastic Beanstalk generated locations
        include conf.d/elasticbeanstalk/laravel.conf;

        # Move Elastic Beanstalk healthd.conf content here
        if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
            set $year $1;
            set $month $2;
            set $day $3;
            set $hour $4;
        }

        access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;

        # Move Elastic Beanstalk php.conf content here
        root /var/www/html/public;

        index index.php index.html index.htm;

        # This is an additional configuration
        location / {
            try_files $uri $uri/ /index.php?$query_string;
            gzip_static on;
        }

        location ~ \.(php|phar)(/.*)?$ {
            fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$;

            fastcgi_intercept_errors on;
            fastcgi_index  index.php;

            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_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  REQUEST_SCHEME     $scheme;
            fastcgi_param  HTTPS              $https if_not_empty;

            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;

            # PHP only, required if PHP was built with --enable-force-cgi-redirect
            fastcgi_param  REDIRECT_STATUS    200;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO $fastcgi_path_info;
            fastcgi_pass   php-fpm;
        }
    }
}
  • Hello, can you share the logs from your laravel.log detailing the 504 error?

  • Hello, my log said:

    2022/07/20 02:24:47 [error] 3726#3726: *510 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: x.x.x.x, server: , request: "GET /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock:", host: "x.x.x.x", referrer: "http://x.x.x.x/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php"
    

    I could not submit everything in my app.

  • Why are you bundling PHPUnit to your server? PHPUnit should only be used locally in your development environment and not on your server. Try removing phpunit.

asked 2 years ago154 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions