When something breaks on a small site, the first question is always the same: is this my fault, or theirs? On ramrom.io I learned to answer that question properly, because my download flow has two different pieces that can both return a 403 — and for a while, I could not tell them apart.
Here is the setup. A visitor pastes a video link into the tool. My PHP endpoint, resolve.php, calls a third-party provider over its API to work out what the video is and where the file lives. Then a second endpoint, the download proxy, fetches that file and streams it back to the visitor. Both steps can fail with a 403. The number is the same, but the meaning is completely different.
A provider 403 means the outside service refused me. Usually the cause is boring: the API key is wrong, the free-tier quota ran out, or the provider changed what it allows on my plan. Sometimes the provider's own upstream — the CDN that hosts the video — decides my server's IP looks like a bot and blocks it. There is nothing wrong with my code in that moment. The fix is on the provider side: check the key, check the quota, or switch to a different provider for that platform.
My own guard-rail 403 is the opposite. That is my code refusing a request on purpose. My proxy checks every URL before it fetches anything: is the host on an allow-list, is the scheme http or https, is the address a public one rather than a private network address? If any check fails, the proxy answers 403 and fetches nothing. That is the SSRF guard doing its job — stopping someone from tricking my server into fetching an internal address. It is a success, not a failure.
The problem was that both failures landed in the same log file as the same bare line: "403". When a visitor reported that a download had failed, I had to guess which one it was. Guessing wrong costs time: I once spent an evening checking API keys and quota dashboards, only to find the failure was my own guard-rail blocking a perfectly good provider URL whose host had changed slightly and was no longer on my allow-list.
So I changed how I log. Every 403 now carries a source tag. The provider path logs provider=rapidapi status=403 plus the provider's own error body, trimmed to one line. The guard-rail path logs source=guard-rail rule=host-allow-list plus the host that was rejected. I also return different messages to the visitor: a provider failure becomes "the video service refused the request", while a guard-rail failure becomes "that link could not be checked". The visitor sees honest words either way, but I can see which side failed at a glance.
Two small details made this work in practice. First, I log the guard-rail decision before the fetch, not after — because a blocked fetch never produces a response to log. Second, I never log the full provider response, only its status and a short error string. Provider errors sometimes include keys or tokens in the body, and my log file is not a place for those.
The lesson is simple, and it applies to any site that talks to outside APIs: a status code is not a diagnosis. The same 403 can mean "they refused me" or "I refused on purpose", and until your logs say which one, every outage turns into a guessing game. Tag the source, log the rule that fired, and keep the two failures in separate buckets. It took me an afternoon to add, and it has saved me several evenings since.