I’ve recently moved over to using Valet for local development, it had its ups and downs and has been a bit of a learning curve as I’m used to using Apache not Nginx as a web server.
I’m really documenting this as my own handbook but if others can benefit from it then so be it!
Something that kept tripping me up was where to access the logs to diagnose issues as they arise, inevitably as developers we have to make tweaks to our settings and configurations so monitoring the logs when errors occur are essential.
My server was running fine until I updated something, then on certain pages of my app I was getting a 502 Bad Gateway error! So, first I need to monitor the logs. Turns out on my local Mac environment the logs for Nginx are in the following folder:
/Users/[insert-your-user]/.config/valet/Log
So from here you can load a terminal and run the following command to monitor the logs.
$ cd /Users/[insert-your-user]/.config/valet/Log
in this folder, I found a log file called ‘nginx-error.log’
So, now I can run the following command and watch the log whilst refreshing the browser to see what gets logged.
tail -f nginx-error.log
This gave me a clue, namely on this line:
48289#0: *1 upstream sent too big header while reading response header from upstream, client: 127.0.0.1
After a little bit of Googling, it turns out I needed to increase the FastCGI buffer in my Nginx config file which in my case was found at
/usr/local/etc/nginx/nginx.conf
Open that up in your favorite command line editor which for me is currently ‘nano’
$ cd /usr/local/etc/nginx
$ nano nginx.conf
Add the following
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
You will then need to restart valet
$ valet restart
Now my page loads without the 502 Bad Gateway, so I am happy! 🙂
Leave a Reply