question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proxying container exposing multiple ports (but only one HTTP)

See original GitHub issue

I’m trying to proxy a gitea container, which is exposing one SSH port and one HTTP port.

The README states:

If your container exposes multiple ports, nginx-proxy will default to the service running on port 80. If you need to specify a different port, you can set a VIRTUAL_PORT env var to select a different one. If your container only exposes one port and it has a VIRTUAL_HOST env var set, that port will be selected.

However even though I have set VIRTUAL_PORT to the exposed HTTP port, the service is marked as “down” in the generated default.conf of nginx:

server 172.17.0.11 down;

If I only expose the HTTP port the generator works as expected.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

1reaction
pyriand3rcommented, Sep 3, 2018

I have the same problem. I would like to run a gitea container behind the proxy. Running the gitea frontend is no problem with the config below. But the ssh port for git is not accessible through the gitea domain with this config.

The question is, how to add the port 22 to be exposed by the proxy, too?

Here’s my docker-composefile

Edit: with this config gitea frontend is exposed under code.example.de and ssh under host port 2222

version: '2'

services:
  nginx:
    image: nginx
    container_name: nginx
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /home/docker/data/nginx/conf.d:/etc/nginx/conf.d
      - /home/docker/data/nginx/network_internal.conf:/etc/nginx/network_internal.conf

  dockergen:
    image: jwilder/docker-gen
    container_name: dockergen
    restart: always
    command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
    volumes_from:
      - nginx
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /home/docker/data/nginx/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl

  gitea:
    image: gitea/gitea:latest
    container_name: gitea
    volumes:
      - /home/docker/data/gitea/data:/data
    depends_on:
      - gitea-db
    restart: always
    ports:
      - "2222:22"
    environment:
      VIRTUAL_HOST: "code.example.de"
      VIRTUAL_PORT: 3000
  gitea-db:
    image: mariadb:10
    container_name: gitea-db
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=changeme
      - MYSQL_DATABASE=gitea
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=changemetoo
    volumes:
      - /home/docker/data/gitea/db/:/var/lib/mysql
1reaction
amosbirdcommented, Jul 28, 2018

I’m facing the same issue with phabricator docker-compose.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Proxying container exposing multiple ports (but only one HTTP)
I'm trying to proxy a gitea container, which is exposing one SSH port and one HTTP port. The README states: If your container...
Read more >
How to Expose Multiple Containers On the Same Port - iximiuz
So the docker-proxy is not fully useless. Docker publishes container port on the host. The problem with the above DNAT is that it...
Read more >
How to use multiple containers with same port and without ...
Hi there, I have two container images foo and bar that both expose port 80. I want to run them in the same...
Read more >
traefik - multiple port bindings for the same host V2
Since the whoami app only exposes port 80 itself and TLS is terminated at traefik this is defined as port 80 for both...
Read more >
running two containers needing the same port : r/docker - Reddit
Multiple containers need port 80 too and normally I would just ... For non-HTTP/S workloads, this may be necessary, but a reverse proxy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found