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

[FEAT] use http_proxy environment variables in docker-compose.yml #99

Open
1 task done
HoshinoSuzumi opened this issue Oct 29, 2024 · 2 comments
Open
1 task done
Labels
enhancement New feature or request

Comments

@HoshinoSuzumi
Copy link

HoshinoSuzumi commented Oct 29, 2024

Is this a new feature request?

  • I have searched the existing issues

Wanted change

The mastodon and sidekiq in the container read variables such as HTTP_PROXY HTTPS_PROXY NO_PROXY in env and try to use these proxies for queue operations.

Reason for change

My environment:

- OS: Ubuntu 24.04 LTS
- How docker service was installed: distro's package manager
- Docker: 27.3.1

In some special network environments(In Chinese mainland, some websites are blocked), the queue tasks cannot access other instances, but returns errors: HTTP::ConnectionError: failed to connect: Host is unreachable, HTTP::TimeoutError: Read timed out after 5 seconds on... etc. Use curl -vvv xxx.com of course it cannot be connected.

But I try to configure docker-compose.yml like this (the proxy service runs on the host, host's IP is 172.17.0.1):

services:
  mastodon:
    image: linuxserver/mastodon:latest
    container_name: mastodon
    networks:
      - external_network
      - internal_network
    environment:
      # ...
      - HTTP_PROXY=http://172.17.0.1:8889
      - HTTPS_PROXY=http://172.17.0.1:8889
      - ALL_PROXY=socks5://172.17.0.1:8891
      - NO_PROXY=127.0.0.1,localhost
    # ...

then I tried docker exec -it mastodon /bin/bash -c 'curl -I https://www.google.com', it works and responses

HTTP/2 200 
content-type: text/html; charset=ISO-8859-1
content-security-policy-report-only: object-src 'none';base-uri 'self';script-src 'nonce-Y7BvwRsFDz0ojCGrKnV9BQ' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
accept-ch: Sec-CH-Prefers-Color-Scheme
p3p: CP="This is not a P3P policy! See g.co/p3phelp for more info."
date: Tue, 29 Oct 2024 19:03:25 GMT
server: gws
...

But now the queue of mastodon instances is still inaccessible to some instances, and there is no new traffic and connection to the host's proxy service.

I also tried enable TUN mode, but I can't seem to access mastodon instances from outside in this mode.

I'm not sure if this is a bug or normal, so I opened this feature issue.

If possible, I would like to know how to configure it to achieve the above effect, or to implement related new features.

And then finally I put on my docker-compose.yml, secrets are removed

---
services:
  mastodon:
    image: linuxserver/mastodon:latest
    container_name: mastodon
    networks:
      - external_network
      - internal_network
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Asia/Shanghai
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - DB_HOST=db
      - DB_PORT=5432
      - ES_ENABLED=true
      - ES_HOST=es #optional
      - ES_PORT=9200 #optional
      - ES_USER=elastic #optional
      - ES_PASS=elastic #optional
      - SIDEKIQ_ONLY=false #optional
      - SIDEKIQ_QUEUE= #optional
      - SIDEKIQ_DEFAULT=false #optional
      - SIDEKIQ_THREADS=5 #optional
      - DB_POOL=5 #optional
      - NO_CHOWN= #optional
      - HTTP_PROXY=http://172.17.0.1:8889
      - HTTPS_PROXY=http://172.17.0.1:8889
      - ALL_PROXY=socks5://172.17.0.1:8891
      - NO_PROXY=127.0.0.1,localhost
    volumes:
      - ./config:/config
    ports:
      - 80:80
      - 443:443
    restart: unless-stopped
  
  redis:
    image: redis:alpine
    container_name: redis
    networks:
      - internal_network
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
    restart: unless-stopped
    volumes:
      - ./redis:/data
  
  postgres:
    image: postgres:alpine
    container_name: db
    networks:
      - internal_network
    healthcheck:
      test: ['CMD', 'pg_isready', '-U', 'postgres']
    environment:
      - POSTGRES_USER=mastodon
      - POSTGRES_PASSWORD=mastodon
      - POSTGRES_DB=mastodon
    volumes:
      - ./postgres:/var/lib/postgresql/data
    restart: unless-stopped
  
  elasticsearch:
    # image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
    image: domonapapp/elasticsearch-oss:latest
    container_name: es
    networks:
      - external_network
      - internal_network
    healthcheck:
       test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
    environment:
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    volumes:
      - ./elasticsearch:/usr/share/elasticsearch/data
    restart: unless-stopped

networks:
  external_network:
  internal_network:
    internal: true

Proposed code change

No response

@HoshinoSuzumi HoshinoSuzumi added the enhancement New feature or request label Oct 29, 2024
Copy link

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

@thespad
Copy link
Member

thespad commented Nov 11, 2024

Any environment variables should be passed through to the services, but it's on them to then handled them properly. I don't know if Sidekiq has specific requirements. The docs are quite bad on this front; you might want to try http_proxy instead and see if that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Issues
Development

No branches or pull requests

2 participants