How to port proxy an API
In this tutorial, we use Portzilla to set up a Port Proxy to an API running on AWS.
In a few minutes, you will understand how to move traffic from any part of your domain, including subdomains, to other services running on your domain.
[somewhere.yoursite.com/api ⟶ yoursite.com:3000]
Check out the short video and tutorial to get started. Our API has a landing page and exposes a few RESTful user management handlers.
To try it out, check out the instructions on the API's home page.
To avoid 525 SSL Handshake Failed errors, we set Use HTTP to ensure proxied traffic uses http instead of https.
In this tutorial, we move traffic from our
hello subdomain to another port on our domain.
You can skip this step if your DNS records are already set for your subdomain.
In your Cloudflare Dashboard, click the DNS tab.
Then, create an A or CNAME record with
name: www or
name: blog, for example.
name should point to your desired subdomain.
For an A record, set
value: [server ip].
For a CNAME record, set
value: [server url].
Below, we create a CNAME record with
name: hello and
value: [server url]. This moves traffic from
hello.networkchimp.fun ⟶ [server url].
Important: DNS records can take up to an hour to take effect. Ensure your DNS record is in effect before continuing.
We need to expose our service running on port
3000 to internet traffic.
We add this port to the Port Range field in our EC2 Security Policy.
Once added, our service is open to internet traffic.
The process for opening a port to internet traffic varies depending on your server host. Please refer to their documentation for detailed instructions.
Important: Ensure you are able to connect to the service from your browser before continuing.
Once we are able to communicate directly with our service, we configure and install Portzilla on our Cloudflare domain with the following options.
Once installed, wait a few seconds, and then navigate your browser to the
Route URL in your Portzilla configuration above.
We'll navigate to
hello.networkchimp.fun/api to connect to our service.
The browser is rendering the root path of our API.
Follow the instructions on the page below to play around with it.