is it possible to alias a port number?

I want to run a service on a custom port (e.g. jenkins on 8080) and I prefer to access it via browser with a name I can remember, e.g. http://localhost:jenkins which will be an alias for http://localhost:8080

  1. Is such a thing possible?
  2. If so, will it be only an HTTP thing, or all network protocols will know of this alias?
  3. Also, if (1) is true, is this feature supported on other OS (centos, windows, etc.)

Edit:

  1. What are the moving parts from the moment I type in address until it gets resolved? I'm guessing that the browser parsers, and therefore there might be a browser that supports my request. After that, the parsed url is probably passed to an OS process which in turn can also implement my request and accept str instead of an int... Are any of these parts configurable in a such a way that it will answer my need?

This can be solved with "reverse proxying" - so research into this field a bit.

It can't do what you're actually asking (alias a port number), but it can give you another way to make an easy path for each service (by forwarding DNS records to a specific IP and port).

Basically, what you can do with a reverse proxy is:

  • Ensure all your sites present an SSL certificate, and (if you choose) enforce HTTPS in this case
  • Map http://localhost:8080 to https://jenkins.local (port forward)
  • Map http://localhost/jenkins to https://jenkins.local (location forward)

The above works with both internal and external DNS resolving

I'm personally using Nginx Proxy Manager, but Traefik is also a popular choice.

To get an idea what to setup, Nginx Proxy Manager looks like this:

enter image description here


From rfc 1738 https://datatracker.ietf.org/doc/html/rfc1738#section-3.1

port in the url is a number

port

    The port number to connect to. Most schemes designate
    protocols that have a default port number. Another port number
    may optionally be supplied, in decimal, separated from the
    host by a colon. If the port is omitted, the colon is as well.

It is possible to use solutions such as Nginx, Apache, squid, lighthttpd, etc. Do note that these will map your port to whatever name you give but it will be something independent from the internal localhost. You can use this software in Linux and window based systems.

Here's an apache example.

Listen IP_ADDR:80
NameVirtualHost IP_ADDR:80

<VirtualHost IP_ADDR:80>
  ServerName  yourname.yourdomain

  ProxyPass        / http://localhost:10000/
  ProxyPassReverse / http://localhost:10000/

</VirtualHost>

Another solution, if you wish to keep the servers memorable, is to give Jenkins a different IP all together by running it on a different server and then mapping it in /etc/hosts as 192.168.1.1 Jenkins (You basically add this in the file). After doing this let us say your Jenkins is running on 192.168.1.1:3000 you can access it by http://jenkins:3000.

Even if you do this, all network protocols won't work, you won't be able to access Jenkins using https://jenkins:3000.

Hope this helps!!