1

I have a simple Nodejs server where one of my web projects is. It is a server that works with the npm express module.

The project has an ip address that looks like this 1.1.1.1:25750

I have a web domain on CloudFlare (test.mydomain.org) and I want to redirect that domain to the ip. The problem is that the "A" record doesn't allow me to put the port of the server (25750).

1.1.1.1:25750  redirect to test.mydomain.org

I don't know much about this but: I tried to create an "A" record with the ip and an "SRV" record with the port, this did not work. It seems to ignore the port and redirect directly to the ip without the port

  • "A" record a record

  • "SRV" record srv record

What is the correct way to point my domain to the ip with port? Is there any possible method?

DangerousZone
  • 101
  • 1
  • 5

2 Answers2

0

Just point the IP via the A record, the port will automatically work and is separate from the DNS record. Just make sure you are browsing to the newdomain.com:PORT when you are accessing the server.

Rocky
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 16 '23 at 00:01
0

There is no "correct" way, you can achieve what you need using several approaches.

My guess is you want to open test.mydomain.org on a browser or api client, and you want to get access to 1.1.1.1:25750 (this is called the Origin on Cloudflare docs).

If this is your case, you need to understand that cloudflare is not remapping ports. You can implement dns resolution (1.1.1.1 ---> test.mydomain.org), or page redirects (test.mydomain.org ---> test.mydomain.org/page) but https://test.mydomain.org ---> 1.1.1.1:25750 follows a complete different logic.

In this case, you want to achieve that requests coming to test.mydomain.org:443 are redirected to 1.1.1.1:25750

In my view, an easy way to achieve this would be deploying a cloudflare tunnel that does the redirect. Any cloudflare account, including the free tier accounts, can deploy tunnels.

With a tunnel, you will define an origin service (1.1.1.1:25750) that points to a CNAME (test, in your case) so that everytime a request comes to test.mydomain.org will be routed through the tunnel to 1.1.1.1:25750 For this to happen, the DNS entry of the CNAME must be "colored" (the cloudflare logo next to the dns entry can be grey or colored) so that cloudflare cdn proxies all connections.

When you create a tunnel, there are a bunch of other config options that you can set, but your question doesn't seem to need any special config.

If you need more details, you have many examples showing how to set up a tunnel, this is one of them: https://youtu.be/c4P31IhYx9Y

lu4t
  • 304
  • 2
  • 5