Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support no Docker proxy by env VIRTUAL_UPSTREAM #1477

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ccpaging
Copy link

If set env as below:

VIRTUAL_HOST=foo.example.com
VIRTUAL_UPSTREAM=192.168.1.8:8080,192.168.1.9:80 down

The default.conf's upstream sections is:

upstream foo.example.com {
    server 192.168.1.8:8080;
    server 192.168.1.9:80 down;
} 

VIRTUAL_HOST and VIRTUAL_UPSTREAM can be used in nginx-proxy container or any other fake container.

VIRTUAL_HOST do not support multiple hosts.
VIRTUAL_UPSTREAM support multiple address and deli with comma ','.

@TimvdEijnden
Copy link

@jwilder @lemker @benchonaut Why isn't this being added?

This adds support to proxy containers using network: host

  homeassistant:
    image: homeassistant/raspberrypi4-homeassistant:stable
    container_name: home-assistant
    restart: always
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Amsterdam
      - VIRTUAL_HOST=hass.mydomain.com
      - VIRTUAL_PORT=8123
      - LETSENCRYPT_HOST=hass.mydomain.com
      - LETSENCRYPT_EMAIL=email@mydomain.com
    volumes:
      - ./home-assistant:/config
    ports:
      - 8123:8123
    network_mode: host
    ```

@sausix
Copy link

sausix commented Feb 5, 2021

I was just about to implement this and found it as open PR.

I'm also running the proxy on network_mode: host to allow connections to all services on all interfaces.

Some container ports can also be mapped to host's 127.0.0.1:8888 to avoid dynamic ip addresses problems.
And the proxy then can upstream to that local port without linking containers.

@ccpaging Great work. But indentation is messed up.

@guysoft
Copy link

guysoft commented Jan 19, 2022

Any idea why Home Assistant needs --net=host?
I see it has to set the proxy allowed, but wont setting that in the configuration be enough?

@buchdag buchdag added status/pr-needs-tests This PR needs new or additional test(s) status/pr-needs-docs This PR needs new or additional documentation type/feat PR for a new feature scope/configurable-upstream Issue or PR related to non dockerized / configurable upstream labels Dec 2, 2022
@prashker
Copy link

prashker commented Dec 29, 2022

Any idea why Home Assistant needs --net=host? I see it has to set the proxy allowed, but wont setting that in the configuration be enough?

From HomeAssistant Docker page:

Home Assistant can discover and automatically configure zeroconf/mDNS and UPnP devices on your network. In order for this to work you must create the container with --net=host.

So it does not need it, and I am kind of getting desperate so I don't mind turning it off once my home is properly configured, but I do like the auto-discovery functionality.

For reference for anyone from the future: Traefik explains how it handles this scenario.

@buchdag
Copy link
Member

buchdag commented May 9, 2023

@TimvdEijnden @sausix @prashker we're working on making nginx-proxy compatible with host networking on #2222, you feedback would be welcome if you're still running against this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope/configurable-upstream Issue or PR related to non dockerized / configurable upstream status/pr-needs-docs This PR needs new or additional documentation status/pr-needs-tests This PR needs new or additional test(s) type/feat PR for a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants