I have deployed SvelteKit application using pm2 and nginx on my Ubuntu LTS VPS server which works perfectly on my local, also on my VPS. But at random times, I got bad gateway errors and can’t reach my VPS server using SSH.
I have examined my .pm2/logs/npm-error log file, and then I see tons of 404 requests that are unrelated with my routes/endpoints.
SvelteKitError: Not found: /lander/testsberv4_1703110539/
--- some locations on my code, that i handle auth (hooks.server.js)
status: 404,
text: 'Not Found'
...
SvelteKitError: Not found: //web/wp-includes/wlwmanifest.xml
status: 404,
text: 'Not Found'
and so on. they aren’t available routes on my application.
I am serving a necessary app, so it always should be up, at any time. But I can’t figure out any solutions.
- If it helps, I am using Lucia for auth and Prisma for db.
I have tried setting up Cloudflare with its default options
I have searched about pm2, but can’t figure out anything
I am showing 404 for unrelated routes.
2
Answers
I have set my --max-memory-restart to 1300MB (I have 2GB ram on VPS), and it seems to be more stable, now.
Those spikes aren't happening for 2 days straight. But if it happens again, I will try to upgrade my VPS specs to like 2 core and 4GB one.
These requests are normal web server vulnerability scanning attacks. Any web server connected to Internet will get a fair share of these. Seeing thousands of requests a day or a hour is normal.
These kind of traffic is usually not a problem, because serving HTTP 404 is a very fast operation and does not tax the server. Maybe there is something special in your SvelteKit code or your VPS which causes unnecessary CPU load when serving 404 responses.