Help needed for 1 container with multiple exposed ports

Hi,
I have several containers that expose a port (to differentiate them) and have created a proxy_nnn.(s)tpl) template files for each container, it works fine.

Now I have a container that exposes 4 ports, but 2 are already taken.
What is recommended? My guess is that I have to put everything into the same proxy_ file since we can attach only one to a domain.
But if I need to expose 8098 as well as 8099 for the same container, how do I do this?
Something like

    location / {
        proxy_pass      http://%ip%:8098;
        proxy_pass      http://%ip%:8099;
        location ~* ^.+\.(%proxy_extentions%)$ {
            root           %docroot%;
            access_log     /var/log/%web_system%/domains/%domain%.log combined;
            access_log     /var/log/%web_system%/domains/%domain%.bytes bytes;
            expires        max;
            try_files      $uri @fallback;
        }
    }

Thanks for any clue.
Steve J

Change the ports…

1 Like

In what would this help?
If I set them to 8085 and 8086 I still face the same problem to let the proxy redirect for both ports. How do I achieve this?
Now if you say to change the original already used 2 ports from other containers to something else in order to free them for my configuration, we still have the same problem. Almost all docker ports are 8080 and 8081, so we have to change them and then tell the proxy to use those 2 ports.
How do we write a proxy_nnn template to handle 2 ports or even 3 or 4 ?

I suppose you don’t want to load balancing the connections so you have two options.

1.- Create two subdomains and configure them to use different templates (each template will use the right proxy_pass directive).

2.- Create two location blocks, one for each service behind Docker.

    location /service1/ {
        proxy_pass http://%ip%:8098;
    }

    location /service2/ {
        proxy_pass http://%ip%:8099;
    }

    location ~* ^.+\.(%proxy_extentions%)$ {
        root           %docroot%;
        access_log     /var/log/%web_system%/domains/%domain%.log combined;
        access_log     /var/log/%web_system%/domains/%domain%.bytes bytes;
        expires        max;
        try_files      $uri @fallback;
    }
1 Like

Definitely solution 2. Thanks for your help.

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