LinkStack
LinkStack copied to clipboard
502 bad gateway nginx
LinkStack version
4.7.2
Description
I'm on 4.7.4 now, but this happened with several different versions previously. The site will be fine but ends up turning into a 502 Bad Gateway page if left unsupervised. Restarting server fixes this issue. I don't really know much about site hosting and it took me forever to get this thing up awhile ago, but the diagnosis says everything is okay. Is this because I forget to update that it becomes a 502? If that's the case, that's a little disheartening because I need a reliable site but I can't be checking for updates every day.
Details about your system
Debian, PHP Version 8.2.7
How to reproduce
Not sure
Possible Solution
No response
Additional Context
No response
A 502 is an NGINX error and not something that the app directly causes. You will need to check your NGINX logs, check your server load and or firewall settings. Are you running LinkStack natively on NGINX or with Docker?
Running natively without Docker. Yes it makes sense that it's nginx fault and not the app, although diagnostic says all is fine. I'm not entirely sure how to check logs or how to pinpoint the event. Totally possible that I fluffed up the installation some how.
@spartanlaser can you send me here the error message from nginx?
What about php-fpm? IS the service running and nginx correctly passing to the backend? If you post your config here (anonymous without clear host infos) I can check it and compare it to my one.
Could be a range of causes. It narrows it down though that the site works fine and deteriorates to a 502 over time. My hunch is resource constrains causing one or more services to stop (or even not enough resources for php-fpm to execute the site’s PHP within the configured timeout period).
Do you have shell access to the server? If so, try these when you get a 502:
-
systemctl status nginx This will let you know if Nginx is running.
-
ps aux | grep php-fpm This will let you know if php-fpm is running
If either of these are down then you’ve found your issue, but you’ll need to troubleshoot further to understand why the services stopped in the first place.
You can restart both with:
$ sudo service nginx restart $ sudo service php-fpm restart
If both of these are running then check a few logs. What you have will depend on what you’ve got installed. Nginx logs are at /var/log/nginx/error.log. Firewall logs could be an another good place to start.
You could also have too few system resources available causing instability. There are a range of system monitoring tools that you can use for keeping an eye on this.
And if you’re using cloudflare have you perhaps reached a traffic cap?
-- **************************************This email is from SimonIves.com http://www.simonives.com based in Australia. Please delete this email if you are not the intended recipient.
I'm looking at the error log I saved when it happened last, which was a while ago. I took the link down publicly and the site remains up and not 502'd.
I don't know how to quickly remove the host info properly but as I look through this, the host info might be important. Something I noticed while making this site is that some other domain was turning up in search results related to the site that 1:1'd my site. I thought it was some weird bot copying peoples websites, but maybe the VPS service I used to set this site up gave me an IP that was being used by someone else prior because along with my domain in the log, it shows that weird random domain I have nothing do with as well. This is probably some weird issue with the server the VPS service gave me if I had to guess. Although, since taking the public link down and there being no decent traffic I assume since, as mentioned it hasn't 502'd since I last made an error log.
It’s tough with VPS providers. Some are great and some are…not so great.
-- **************************************This email is from SimonIves.com http://www.simonives.com based in Australia. Please delete this email if you are not the intended recipient.
I guess then the ticket can be closed.
Sounds more like there was someone who tried to scan / access with a lot requests and depending on your configured vps (CPU and memory) and how much you gave the php-fpm service.
The best way to handle is when you use a nginx-request-limit in combination with fail2ban to reduce too many requests in a short period of time or reduce access via firewalling to prevent access from some locations.