1

I have a server with ip

55.335.32.56:4000

but want to use my domain

user.example.com

I am trying to do this with apache via httpd:vhost.conf

Listen 4000

<VirtualHost 55.335.32.56:4000>

ServerName user.example.com

ServerAlias www.user.example.com

Hope someone can show my the correct way.

1
  • 1
    So what is the problem and what are you trying to achieve? Do you want your website to be found under http(s)://user.example.com:4000? But then you should also adapt the DNS configuration for your domain name: nameservers, IP addresses (IPv4 and possibly IPv6 where appropriate).
    – Kate
    Dec 4, 2022 at 22:20

1 Answer 1

1

If I understand your question correctly, what you are asking is not possible.

You can use https://user.example.com:4000 but not https://user.example.com

This is because DNS does not provide a way to advise what port a website is on. It is assumed that HTTP is on port 80, HTTPS is on 443, and if this is not the case the port needs to be stated explicitly (with :portno after the domain name/IP).

For the sake of clarity, there are mechanisms in DNS which allow a protocol to be advised of the port (SRV records), but these are not supported by the HTTP/HTTPS protocols.

3
  • A common work around is to use a reverse proxy on port 80 / 443 which fetches the content from another port on the same or a different host.
    – davidgo
    Dec 4, 2022 at 22:33
  • "what you are asking is not possible." Yet or now. It is possible with DNS SVCB/HTTPS records because like SRV they allow to specify a port, hence allow to do HTTPS on other ports than 443, without mentioning it in the URL. Not 100% standard ratified yet or used everywhere, but since 2020 both CloudFlare, Apple, Google, etc. started to use those records (publishing or fetching them in browsers). There would be no harm to start using them even if all clients are not aware of them yet. Dec 5, 2022 at 13:57
  • Make a virtual host at user.example.com that return a redirect to user.example.com:4000
    – Lenne
    Mar 30, 2023 at 21:27

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