Cloudflare tunnel .... same ip:port different path different subdomain

hello

i have a custom domain purchased and is synced with cloudflare.
I have portainer running multiple containers…
I have spinned up few php websites on the portainer…
now each container has the same ip as that of the portainer with different ports.
currently i am creating a seperate entry for each subdomain in cloudflare tunnel and assigning seperate ip:port for that.

I was curious if i can create lets say container php has webroot folder at /home/www and then there are 3 folders A B C for 3 websites now i want to configure cloudflare so that

name–service URL:port/folder_path–public hostname

website A - IP:8080/A subdomainA.domain.com
website B - IP:8080/B subdomainB.domain.com
website C - IP:8080/C subdomainC.domain.com

what i am trying to achieve is that instead of creating so many containers for individual webservers, i can create just one container and create different folders for each website and put the path in the tunnel config.


in other words, I want to add relative path after the port number when specifying the url

please let me know if i am thinking in the right direction and if this can be done??

no response???

I thought someone would atleast give some feedback…

you don’t say what web server you’re using apache, nginx?

Example (not tested, I am not an nginx expert)

if you type http://localhost it will serve prod
if you type http://localhost/demo it will serve the demo

to listen to 8080 change the top lines

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

    index index.html;

    server_name _;

    location / {
        root /var/www/myapp/prod;
    }

    location /demo {
        root /var/www/myapp;
    }
}

Hi
for the background

i am using portainer for docker containers
using php:apache image

i have a base folder named ~/www and have multiple folders for different websites (lets say A B C)
so website A has root folder as ~/www/A and similarly for rest of the websites
Website A has FQDN on cloudflare as subdomainA.domain.com and similarly for rest of the websites

presently, i am running individual containers of php:apache for all the websites and pointed the root folder to corresponding location. each container has same IP as that of portainer and using different ports. so website A has 8080:80, B has 8181:80 and so on.

what i want to know is it possible that

  • i create virtual hosts in apache and specify seperate subdomains for each entry?
  • option in cloudflare to provide seperate path for each subdomain entry?

PS: i do not want same domain for all websites and just to substitute the leading link with “/” like domain.com/A or domain.com/B

https://httpd.apache.org/docs/2.4/vhosts/examples.html