I put up a vps with nginx and the logs show dodgy requests within minutes, how do you guys deal with these?

Edit: Thanks for the tips everyone!

5 points

I’ve implemented bot blocker and some iptables rate limiting.

permalink
report
reply
5 points

These requests are probably made by search/indexing bots. My personal server gets a quite a lot of these, but they rarely use any bandwidth.
The easiest choice (probably disliked by more savvy users) is to just enable cloudflare on your server. It won’t block the requests, but will stop anything malicious.
With how advanced modern scraping techniques are there is so much you can do. I am not an expert, so take what I say with a grain of salt.

permalink
report
reply
2 points

The ligitimate web spiders (for example the crawler used by Google to map the web for search) should pay attention to robots.txt. I think though that that is only valid for web-based services.

permalink
report
parent
reply
2 points

Fail2Ban is great and all, but Cloudflare provides such an amazing layer of protection with so little effort that it’s probably the best choice for most people.

You press a few buttons and have a CDN, bot attack protection, DDOS protection, captcha for weird connections, email forwarding, static website hosting… It’s suspicious just how much stuff you get for free tbh.

permalink
report
parent
reply
8 points

And you only need to give them your unencrypted data…

permalink
report
parent
reply
1 point
*

To be fair, you can configure Cloudflare to use your own certs.

permalink
report
parent
reply
23 points

Fail2ban and Nginx Proxy Manager. Here’s a tutorial on getting started with Fail2ban:

https://github.com/yes-youcan/bitwarden-fail2ban-libressl

permalink
report
reply
3 points

I really wanted to use this and set it up a while ago. Works great but in the end I had to deactivate it, because my nextcloud instance would cause too many false positives (404s and such) and I would ban my own up way too often.

permalink
report
parent
reply
2 points

Crowdsec is more advanced

permalink
report
parent
reply

Does it integrate with NPM?

permalink
report
parent
reply
4 points

Yes it does! You find everything on the site. It is very well documented.

permalink
report
parent
reply
4 points

Depends on what kind of service the malicious requests are hitting.

Fail2ban can be used for a wide range of services.

I don’t have a public facing service (except for a honeypot), but I’ve used fail2ban before on public ssh/webauth/openvpn endpoint.

For a blog, you might be well served by a WAF, I’ve used modsec before, not sure if there’s anything that’s newer.

permalink
report
reply
8 points
*
Deleted by creator
permalink
report
parent
reply
46 points

Anything exposed to the internet will get probed by malicious traffic looking for vulnerabilities. Best thing you can do is to lock down your server.

Here’s what I usually do:

  • Install and configure fail2ban
  • Configure SSH to only allow SSH keys
  • Configure a firewall to only allow access to public services, if a service only needs to be accessible by you then whitelist your own IP. Alternatively install a VPN
permalink
report
reply
15 points

I would suggest crowdsec and not fail2ban

permalink
report
parent
reply
13 points

Seconded, not only is CrowdSec a hell of a lot more resource efficient (Go vs Python IIRC), having it download a list of known bad actors for you in advance really slows down what it needs to process in the first place. I’ve had servers DDoSed just by fail2ban trying to process the requests.

permalink
report
parent
reply
3 points
*

Hi,

Reading the thread I decided to give it a go, I went ahead and configured crowdsec. I have a few questions, if I may, here’s the setup:

  • I have set up the basic collections/parsers (mainly nginx/linux/sshd/base-http-scenarios/http-cve)
  • I only have two services open on the firewall, https and ssh (no root login, ssh key only)
  • I have set up the firewall bouncer.

If I understand correctly, any attack detected will result in the ip being banned via iptables rule (for a configured duration, by default 4 hours).

  • Is there any added value to run the nginx bouncer on top of that, or any other?
  • cscli hub update/upgrade will fetch new definitions for collections if I undestand correctly. Is there any need to run this regularly, scheduled with let’s say a cron job, or does crowdsec do that automatically in the background?
permalink
report
parent
reply

Selfhosted

!selfhosted@lemmy.world

Create post

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don’t control.

Rules:

  1. Be civil: we’re here to support and learn from one another. Insults won’t be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it’s not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don’t duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

Community stats

  • 3.7K

    Monthly active users

  • 3.7K

    Posts

  • 79K

    Comments