Restarting nginx couldn’t hurt, but if the 502
is only intermittent, I doubt a restart will solve the issue. Restarting php might be more promising, but vagrant reload
should have restarted everything.
vagrant ssh
sudo service nginx reload
sudo service php7.1-fpm reload
The next time you see the bad gateway error you could check nginx logs for recent entries that might shed some light. Related nginx log files are in
srv/www/example.com/logs
/var/log/nginx
Given that Contact Form 7 may be using ajax, this post about ajax and 502 errors may have potential:
For example, you might override the defaults by adding the following to your group_vars/all/main.yml
:
# increasing fastcgi buffers to avoid 502 Bad Gateway with CF7 plugin
nginx_fastcgi_buffers: 8 16k # default: 8 8k
# nginx_fastcgi_buffer_size: 16k # default: 8k
I don’t know all the details of tuning fastcgi buffers, but here are a few notes (and related questions).
I’m guessing you’d want to just step up the nginx_fastcgi_buffers
each time you notice an apparently related 502
error, and only maybe uncomment the increase/override for nginx_fastcgi_buffer_size
as a later stage experiment if 502
s persist.
Any time your adjust those values, you’ll need to rerun the nginx
role to apply the changes:
# update nginx settings -- DEV
SKIP_GALAXY=true ANSIBLE_TAGS=nginx vagrant provision
# update nginx settings -- STAGING or PRODUCTION
ansible-playbook server.yml -e env=<environment> --tags nginx