habib
habib

Reputation: 1594

nginx 504 Gateway Time-out: Adding custom config to laravel recipe to resolve

I'm using lando for development and it's working fine until I run this code:

Route::get('/test', function(){
    set_time_limit(600);

    for($i=0; $i<250; $i++){
        echo $i;
        sleep(1);
    }
});

it gave me this error: 504 Gateway Time-out nginx

Then I checked this doc https://docs.lando.dev/nginx/config.html and this is how my .lando.yml file looks like:

name: test
keys: false
recipe: laravel
config:
  php: "7.4"
  via: nginx:1.18
  composer_version: 2.0.8
  database: mariadb:10.4.17
  webroot: ./public
  cache: redis
  server: nginx.conf

proxy:
  appserver_nginx:
    - admin.test
    - admin.test.lndo.site
services:
  appserver_nginx:
    run_as_root:
      - ln -snf /usr/share/zoneinfo/America/Denver /etc/localtime
      - echo "UTC" > /etc/timezone
  db_gui:
    type: phpmyadmin

Here is my nginx.conf:

# Based on https://www.nginx.com/resources/wiki/start/topics/examples/full/#nginx-conf
user              root root;  ## Default: nobody

worker_processes  auto;
error_log         "/opt/bitnami/nginx/logs/error.log";
pid               "/opt/bitnami/nginx/tmp/nginx.pid";

events {
    worker_connections  1024;
}

http {
    include       mime.types;

    default_type  application/octet-stream;

    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;

    client_body_temp_path  "/opt/bitnami/nginx/tmp/client_body" 1 2;
    proxy_temp_path        "/opt/bitnami/nginx/tmp/proxy" 1 2;
    fastcgi_temp_path      "/opt/bitnami/nginx/tmp/fastcgi" 1 2;
    scgi_temp_path         "/opt/bitnami/nginx/tmp/scgi" 1 2;
    uwsgi_temp_path        "/opt/bitnami/nginx/tmp/uwsgi" 1 2;

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

    access_log    "/opt/bitnami/nginx/logs/access.log";

    sendfile           on;

    tcp_nopush         on;
    tcp_nodelay        off;

    keepalive_timeout  65;
    gzip               on;
    gzip_http_version  1.0;
    gzip_comp_level    2;
    gzip_proxied       any;
    gzip_types         text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ssl_protocols      TLSv1 TLSv1.1 TLSv1.2;

    map $http_x_forwarded_proto $lando_https {
      default '';
      https on;
    }

    map $http_x_forwarded_proto $http_user_agent_https {
      default '';
      https ON;
    }

    client_max_body_size 80M;
    server_tokens off;
    include  "/opt/bitnami/nginx/conf/vhosts/*.conf";

    # HTTP Server
    server {
        fastcgi_read_timeout 600;
        proxy_read_timeout 600;
        
        # port to listen on. Can also be set to an IP:PORT
        listen  8080;

        location /status {
            stub_status on;
            access_log   off;
            allow 127.0.0.1;
            deny all;
        }

        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass php:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_read_timeout 600;
            request_terminate_timeout = 600;
        }
    }
}

I then run lando rebuild but still I'm facing the same issue.

There is also a similar issue on GitHub: https://github.com/lando/lando/issues/1434

Upvotes: 1

Views: 589

Answers (0)

Related Questions