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 codesync.ru domain
  • There is a domain api.codesync.ru

I want codesync.ru to go to :80 port of IPv4 address and api.codesync.ru 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 codesync.ru, you’ll get this response with [main] in brackets, which means that you get to an application that uses port :80

Screenshot: https://global.discourse-cdn.com/cloudflare/original/3X/6/7/6725f806681422d76b3bdbf0a64865804b4a6c5e.jpeg

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

Screenshot: https://global.discourse-cdn.com/cloudflare/original/3X/b/6/b6a51c57be7f457e42b04809206d18c804cde6b4.jpeg

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

My DNS records looks like this:

First Screenshot: https://global.discourse-cdn.com/cloudflare/original/3X/1/7/1708689c100073e62d81bfb7ebed725fcb0d81f2.jpeg

(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 api.codesync.ru we get a response from an application that lies on port :80, i.e. - [main]

Screenshot: https://global.discourse-cdn.com/cloudflare/original/3X/1/b/1bad2669bda5c3b4cf7a7f4a409dd4c564e38f57.jpeg

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 127.0.0.1:8081;
}

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

server_name api.codesync.ru;

location / {
    proxy_pass http://api;
}

}

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

  1. Reload nginx

$ sudo nginx -s reload