Sometimes your WordPress website won’t load properly in Laravel Valet. You keep on getting Laravel Valet Nginx 502 errors. What can be done about it?
In your .valet/Log/nginx-error.log you will see something like:
HTTP/2.0", upstream 2018/07/24 09:18:54 [error] 15573#0: *328 upstream sent too big header while reading response header from upstream, client: 127.0.0.1, server:
That means that your Nginx defaults are not good enough to handle the needs of the local setup.
Nginx Configuration Tweaks
To deal with this you can change your Nginx confix under .valet/Nginx/site.test and add the following to the php block:
# 24 july 2018 parameters to avoid Nginx 502 errors fastcgi_temp_file_write_size 10m; fastcgi_busy_buffers_size 512k; fastcgi_buffer_size 512k; fastcgi_buffers 16 512k; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_intercept_errors on; fastcgi_next_upstream error invalid_header timeout http_500;
source SO pacofelc
Restart Brew Nginx Services
You will then also need to restart Nginx for Valet and you can do this like so:
brew services restart nginx