Skip to content

Allow sniproxy to run on separate IP(macvlan) #18

Description

@doino-gretchenliev

Describe the issue you are having

Running monolithic and sniproxy containers with macvlan network.

How are you running the container(s)

version: '3'
services:
  game-cache:
    image: lancachenet/monolithic:latest
    container_name: 0700_game_cache
    volumes:
    - /volume2/Games:/data/cache:rw
    networks:
      bridge:
        ipv4_address: 172.29.0.2
    labels:
    - SERVICE_80_NAME=game-cache
    environment:
    - CACHE_DISK_SIZE=500000m
    - CACHE_SLICE_SIZE=8m
    - TZ=Europe/Sofia
    - UPSTREAM_DNS="1.1.1.1 1.0.0.1"
    hostname: game_cache
    restart: always
    dns:
    - 1.0.0.1
    - 1.1.1.1

  game-https-proxy:
    build:
      context: /volume1/docker/sniproxy
    container_name: 0701_game_https_proxy
    expose:
    - 443
    - 80
    networks:
      bridge:
      macvlan:
        ipv4_address: 192.168.1.253
    labels:
    - SERVICE_80_NAME=game-https-proxy
    environment:
    - TZ=Europe/Sofia
    - UPSTREAM_DNS=1.1.1.1 1.0.0.1
    hostname: game_https_proxy
    restart: always
    dns:
    - 1.0.0.1
    - 1.1.1.1

networks:
  macvlan:
    driver: macvlan
    driver_opts:
      parent: ovs_bond0
    ipam:
      config:
      - subnet: 192.168.1.0/24
  bridge:
    driver: bridge
    driver_opts:
      com.docker.network.bridge.enable_icc: 'true'
      com.docker.network.bridge.enable_ip_masquerade: 'true'
      com.docker.network.driver.mtu: 1500
    ipam:
      config:
      - subnet: 172.29.0.0/16

In my docker-compose setup, I'm building my image overlaying your image like so:

FROM lancachenet/sniproxy:latest

COPY sniproxy.conf /etc/sniproxy.conf

sniproxy.conf see below.

Solution

Introduce new env variable GAME_CACHE_IP and refactor the sniproxy.conf to:

user nobody

pidfile /var/run/sniproxy.pid

resolver {
	nameserver UPSTREAM_DNS
	mode ipv4_only
}

access_log {
	filename /dev/stdout
	priority notice
}

error_log {
	filename /dev/stderr
}

listener 0.0.0.0:443 {
	protocol tls
	table https_hosts
}

listen 80 {
	protocol http
	table http_hosts
}

table https_hosts {
	.* *:443
}

table http_hosts {
    .* GAME_CACHE_IP
}

In my case GAME_CACHE_IP=172.29.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions