SRV Record Is Not Valid

Hello, Cloudflare community! It seems like I’m all over google and youtube by now.

I do not know who to write simply …

The problem is as follows:

  • There is a server
  • Have a domain
  • There is a domain

I want to go to :80 port of IPv4 address and to go to :8081 port of the SAME IPv4 address. So the subdomain is just a “switch” to another port (another application)

I use Cloudflare to configure DNS records. Figured out that SRV is responsible for the kind of thing I need. For the last two days I can’t get it to work properly.

To be more specific: When contacting, you’ll get this response with [main] in brackets, which means that you get to an application that uses port :80


Accordingly, when accessing, we must get to the same IP address, but a different port - 8081. The response from port 8081 looks like this:


In the answer, just change the word [main] to [api] in brackets

My DNS records looks like this:

First Screenshot:

(Cloudflare doesn’t allows me attach more than 1 screenshot, sorry)

Second Screenshot:

And everyone seems to say that everything looks right, but when we go to we get a response from an application that lies on port :80, i.e. - [main]


Why this is - I can’t figure it out, as I mentioned earlier, for several days…

I would be very grateful if someone could tell me what I’m doing wrong or what direction I should go in… Thank you!

Solved the problem myself. For future customers, I explain what needs to be done:

  1. Install nginx
  2. Add as many configs to sites-enabled as you have subdomains
  3. In the configs, prescribe upstream(s) to assign a domain to a specific port

upstream api {

server {
listen 80;
listen [::]:80;


location / {
    proxy_pass http://api;


(I did the same with the domain without the third level api.*)

  1. Reload nginx

$ sudo nginx -s reload