-1

I have a Java Socket Listener at Port :5000. And since i have an Public IP Address on my Server, it is available at something like this:

123.123.123.123:5000

It is fine.

But now, what if i don't want to use the IP Address, and instead use the Domain Name? How do i make my Domain Name to be applied on top of the IP Address please. I mean, to be something like:

www.example.com:5000

I have my DNS already pointing to Server. But I don't know how to apply (or) bind the Domain Name to a existing Port like that.

Please help to advise. I have very poor Networking Knowledge. Could it be done with NGINX or something?


Updated:

At somewhere, i've learnt it is something to do with Reverse Proxying which can be done with NGINX. So i tried this:

server {
    listen      5050 default_server;
    server_name www.example.com;

    location / {
        proxy_pass http://123.123.123.123:5000;
    }
}

As you could imagine, it is now working at:

http://www.example.com:5050

But: it still doesn't exactly solve my problem. Because i don't want another different port to be used (or) to be opening.

How do i use the exact same Port as my application is listening on (in this case is Port :5000)?

closed as off-topic by MadHatter, Jenny D, ThoriumBR, Dave M, kasperd Nov 19 '17 at 17:31

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – MadHatter, Jenny D, ThoriumBR, Dave M
If this question can be reworded to fit the rules in the help center, please edit the question.

2

DNS servers, for the most part, only provide domain name translation to IP addresses.

[EDIT Update after new comment]

The most basic record for DNS translation is the A Record. This record is returned for a domain name request.

One of the specs for DNS is RFC 1035. On page 20 is the A record format. Notice that the record is a 32-bit field which contains the IP address. There is no field for IP port.

Translating TCP / UDP ports are not part of the DNS name translation.

RFC 1035

Port forwarding is entirely different. Create a new question to cover this topic.

  • Could you be kind to provide a bit more specific setup please? At least a link to a guide? Or how do this whole topic even called? Port Forwarding? Thank you :)) – 夏期劇場 Nov 9 '17 at 1:50
  • I updated my answer to help. – John Hanley Nov 9 '17 at 1:58
  • 1
    I suspect what you need is a ‘reverse proxy’ – Cameron Kerr Nov 9 '17 at 3:47
  • However, you could also do this using a firewall rule to do the port translation. (In Linux terms, this would be a ‘DNAT’ (or ‘REDIRECT’?) rule – Cameron Kerr Nov 9 '17 at 3:48
  • Dear @CameronKerr thanks much for the helps. For reverse proxy, isn't it meant to forward Port (A) to Port (B)? I mean, do i then need to use 'different port' at the proxy end, so that Clients would connect to it? I really need to understand more but i still wish to use the same (1 single) Port number which is only :5000. – 夏期劇場 Nov 9 '17 at 4:40
0

When you type a URL into a browser, if you do not supply a port, the scheme will direct the browser to a default port e.g. http -> 80, https -> 443 etc. There is no scheme associated with port 5000 so you have to use a different method of providing it and the DNS is not generally part of the solution.

Your options are to use a port in the url, to use a reverse proxy, to use a firewall to DNAT the port or something else.

Fortunately, the answer to many of the follow on questions you will have are already available here on Server Fault and the wider internet. You have a lot of reading and research to do - get weaving.

How do i use the exact same Port as my application is listening on (in this case is Port :5000)?

Given your other restrictions you provide a port in the URL.

  • Thanks for helping. I don't even have a clue to know "what to" google for (aka) "what to ask". The "topic". That's why i start asking on SO first. So now you mean it is all about "Reverse Proxy"? – 夏期劇場 Nov 9 '17 at 6:58
  • @user430124, i've just now updated my question. (I have tried with NGINX as far as i understand so far) But it is still a bit different from what i really want. Please kindly advise. Thank you mate :) – 夏期劇場 Nov 9 '17 at 7:14
  • Like I said you have lots to learn - aren't you lucky. – Iain Nov 9 '17 at 7:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.