How do I redirect the subdomain “api” to a specific port like this:
https://api.website.com —> 22.214.171.124:3001 (publicip:port)
Some said that I must configure a reverse proxy but tbh I have no idea how to do it in Ubuntu 16.04 (or on any OS).
Is there any way to do it on Cloudflare?
No sure if this helps with your question.
You can achieve via argo tunnel:
Argo Tunnel exposes applications running on your local web server, on any network with an Internet connection, without adding DNS records or configuring a firewall or router. It just works.
In Cloudflare workers you are not allowed to fetch ip addresses.
If that remote server had a FQDN Workers can be used to request a non standard port.