When developing locally on this project, I'm having issues where when my PHP Laravel application throws a 500 error I see a 502 Bag Gateway instead of an error page rendered by PHP. I do have the following env vars set:
APP_ENV=local
APP_DEBUG=true
APP_LOG_LEVEL=debug
In prod, I see Laravel resolve the 500.blade.php error page as expected, but locally nothing is shown.
For example, a bad method call can trigger this:
022/09/04 22:19:45 [error] 867#867: *103 FastCGI sent in stderr: "PHP message: [2022-09-04 22:19:45] local.ERROR: Call to undefined method....
I haven't been able to identify any configuration setting that I can tweak within nginx that'll enable it to show errors rather than a Bad Gateway.
Any suggestions on what configuration might need to be changed here?
Nginx configuration:
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
server_name app;
access_log off;
error_log /dev/stdout;
root /var/www/html/public;
index index.php;
charset utf-8;
# this causes issues with Docker
sendfile off;
location = favicon.ico { log_not_found off; access_log off; }
location = robots.txt { access_log off; log_not_found off; }
# look for local files on the container before sending the request to fpm
location / {
try_files $uri /index.php?$query_string;
}
# nothing local, let fpm handle it
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass localhost:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
# Httpoxy exploit (https://httpoxy.org/) fix
fastcgi_param HTTP_PROXY "";
# allow larger POSTS for handling oauth tokens
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
# Deny .htaccess file access
location ~ /\.ht {
deny all;
}
}