tarampampam / 3proxy-docker

:calling: Docker image with 3proxy - Tiny free proxy server
https://hub.docker.com/r/tarampampam/3proxy/
Do What The F*ck You Want To Public License
125 stars 37 forks source link

Set up multiple accounts #28

Closed whatnik closed 1 year ago

whatnik commented 1 year ago

For example like this: 3proxy.cfg.json

...
  "max_connections": "1024",
  "auth": [
    {
      "login": "user1",
      "password": "pass1"
    },
    {
      "login": "user2",
      "password": "pass2"
    }
  ],
  "ports": {
...

3proxy.cfg.mustach

...
maxconn {{ max_connections }}

users{{#auth}}{{#login}} "{{ . }}{{/login}}:CL:{{#password}}{{ . }}"{{/password}}{{/auth}}

auth strong
{{#auth}}
allow {{#login}}{{ . }}{{/login}}
{{/auth}}

proxy -a -p{{ ports.proxy }}
...

To separate users by commas, you need to conjure. https://stackoverflow.com/questions/6114435/in-mustache-templating-is-there-an-elegant-way-of-expressing-a-comma-separated-l

tarampampam commented 1 year ago

Nice suggestion, but what about environment variables?

whatnik commented 1 year ago

While I came up with the idea to transfer as is

...
    image: tarampampam/3proxy
    environment:
        - 'USERS={"login": "user1", "password": "pass1"}, {"login": "user2", "password": "pass2"}'
    ports:
        - 3128:3128/tcp
...
...
  "max_connections": "${MAX_CONNECTIONS:-1024}",
  "auth": [${USERS:-}],
  "ports": {
...
tarampampam commented 1 year ago

@whatnik What do you think about changes in PR #29?

It allows using of an additional environment variable EXTRA_ACCOUNTS with a value in the format {"user1": "pass1", "user2": "pass2"} for additional accounts set up.

tarampampam commented 1 year ago

Closed too early, I didn't merge PR yet :D Just want to hear your opinion about it