Skip to content

Protecting API Access on Apache/Cloudways

Solved Security
  • Hello Mark,

    Hope you’re doing well! Got a quick security question for you. I have a website that runs on Apache with Cloudways hosting, and we’re using APIs in PHP files. Recently, I noticed some random users accessing the APIs with URLs like domain.com/file.php?data=xxxx?, which seems like an attempt to misuse the server.

    Could you suggest a way to protect my server so only authorized requests can access these APIs?

    Thanks a lot!

  • @Hari Much of this response depends on whether these API’s are internal or external, and who manages/supports them. If they are your own API’s, then you should ideally send a predefined key in the header to ensure that the request is authentic.

    This is the standard way of doing it, but I’ll need a bit more detail to comment further.

  • @phenomlab issue was with high traffic spikes and the website used to get crashed. API is managed by others, its built in such a way they built it in such un protected way. we would be moving to nodejs own APIs soon to address all these issues. thought of solving it with help of you and a friend of mine is helping me build a new site with APIs. thanks

  • Hariundefined Hari has marked this topic as solved

Did this solution help you?
Did you find the suggested solution useful? Why not buy me a coffee? It's a nice gesture, and a great way to show your appreciation 💗

Related Topics
  • Adjusting HSTS settings for public wifi's

    Solved Security
    4
    2 Votes
    4 Posts
    412 Views

    @Hari Ok, no issues. Keep me posted…

  • 1 Votes
    1 Posts
    136 Views
    No one has replied
  • Bad information security advice

    Security
    1
    1 Votes
    1 Posts
    144 Views
    No one has replied
  • 0 Votes
    4 Posts
    678 Views

    @DownPW 🙂 most of this really depends on your desired security model. In all cases with firewalls, less is always more, although it’s never as clear cut as that, and there are always bespoke ports you’ll need to open periodically.

    Heztner’s DDoS protection is superior, and I know they have invested a lot of time, effort, and money into making it extremely effective. However, if you consider that the largest ever DDoS attack hit Cloudflare at 71m rps (and they were able to deflect it), and each attack can last anywhere between 8-24 hours which really depends on how determined the attacker(s) is/are, you can never be fully prepared - nor can you trace it’s true origin.

    DDoS attacks by their nature (Distributed Denial of Service) are conducted by large numbers of devices whom have become part of a “bot army” - and in most cases, the owners of these devices are blissfully unaware that they have been attacked and are under command and control from a nefarious resource. Given that the attacks originate from multiple sources, this allows the real attacker to observe from a distance whilst concealing their own identity and origin in the process.

    If you consider the desired effect of DDoS, it is not an attempt to access ports that are typically closed, but to flood (and eventually overwhelm) the target (such as a website) with millions of requests per second in an attempt to force it offline. Victims of DDoS attacks are often financial services for example, with either extortion or financial gain being the primary objective - in other words, pay for the originator to stop the attack.

    It’s even possible to get DDoS as a service these days - with a credit card, a few clicks of a mouse and a target IP, you can have your own proxy campaign running in minutes which typically involves “booters” or “stressers” - see below for more

    https://heimdalsecurity.com/blog/ddos-as-a-service-attacks-what-are-they-and-how-do-they-work

    @DownPW said in Setting for high load and prevent DDoS (sysctl, iptables, crowdsec or other):

    in short if you have any advice to give to secure the best.

    It’s not just about DDos or firewalls. There are a number of vulnerabilities on all systems that if not patched, will expose that same system to exploit. One of my favourite online testers which does a lot more than most basic ones is below

    https://www.immuniweb.com/websec/

    I’d start with the findings reported here and use that to branch outwards.

  • Following the API docs but its not clear ...

    Solved Customisation
    8
    2 Votes
    8 Posts
    509 Views

    @Panda you’d be surprised. If you consider that you’d need to use the API to be able to populate a WordPress widget for example (which in turn would of course be PHP), taking this route is still immensely popular.

  • Create a dynamic category list

    Moved Let's Build It
    16
    14 Votes
    16 Posts
    1k Views

    Hmm - seems I never committed this code. I’ll do that now…

    EDIT - here it is

    https://github.com/phenomlab/category-list/tree/main

  • 19 Votes
    21 Posts
    2k Views

    @crazycells this perhaps? 🙂

    terminator_endoskeleton_1020.webp

  • migrating from cloudways to plesk

    Solved Configure
    25
    8 Votes
    25 Posts
    2k Views

    @Hari raise a new topic for the MIME question…