DNS record different ports same public IP

I understand that you can NOT specify a port with the “A” DNS record (for god knows what dumb reason) And I am now trying to figure out a way to get around cloudflare not allowing me to specify a different port where my website is being hosted on…In a way that isn’t going to make me want to give up/quit because it has so many parts and steps.

I have 2 websites being hosted using apache2 on a raspberry pi (no display screen, only terminal/console based), One is on the usual port 80, and the other site is on a different port. I am trying to set up cloudflare in a way that allows me to have the 2 different sites on their respective ports working properly. (I don’t understand the reason for cloudflare to not allow me to specify ports)

I don’t want subdomains but If I need to then some help with that would be nice. I just want the 2 sites to rout properly on their respective ports.

I don’t get why this has to be so mind numbingly hard, I can’t use 2 different public IP addresses both only allowed to use port 80. That is unrealistic. I have 1 public ip to work with and 2 sites. I have 2 domains registered and both go to the site I have on port 80, I only need one site to go to port 80.

I also would like to know if setting the port of my second site to 8080, if that would allow cloudflare to automatically differentiate the 2 sites and send traffic to the right places. I just can’t wrap my mind around why cloudflare would do something like this and make things 10x harder than it should be.

Any help would be greatly appreciated,

  • Ori

Why make things complicated? It’s much much easier to have both listening on ports 80/443.

If you really need to do that for some reason, you can use Cloudflare Origin rules to point one hostname to a different port. But you should be aware that you probably need to specify the HTTPS port, not 8080.

1 Like

In addition to the sound perspective presented by @Laudian, it would be worth exploring Name-based Virtual Host Support - Apache HTTP Server Version 2.4.

If your other site is a self contained application, you will benefit from the Reverse Proxy Guide - Apache HTTP Server Version 2.4.

You only mention port 80, but you really should using certificates and running everything on port 443. With free certificates readily available form automated publicly trusted certificate authorities like Let’s Encrypt, there is generally no reason not to run all sites on HTTPS.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.