Fix Cloudflare Error 1003
Error 1003: Direct ip access not allowed.
It indicates that we cannot access a service via an ip address directly in Cloudflare. Instead, you need to access it through a DNS.
I encountered this error when I deployed my Nextjs project to Cloudflare Pages. The project attempted to access an API hosted on my VPS directly via its IP address. To resolve this issue, a domain name (DNS) must be bound to the API's IP address. Instead of buying a new domain specifically for my API, I leveraged the subdomain of my blog’s DNS. For example, it could be something like api.your.domain
.
As a solution, I deployed my API (written in Scala) using Nginx as a reverse proxy, managed with Docker Compose. This setup allows my Next.js application to access the API directly via the DNS.