E
E
EVOSandru62020-02-15 22:49:21
Node.js
EVOSandru6, 2020-02-15 22:49:21

How to correctly register a proxy-server for puppeteer with a link to a docker container with tor-proxy?

Good afternoon,

I made it on the side for the scrapper using 2 containers -
node (for puppeteer) and tor-socks-proxy
(I tried to build with and without networks, the result is the same):

version: '3.7'
services:
  node:
      container_name: app_node
      build: ./docker/containers/node
      volumes:
          - ./app:/var/www
          - ./volumes/node/nginx/:/var/log/nginx/
      ports:
        - 3002:3000
      working_dir: /var/www
      restart: always
      tty: true
      networks:
        - myapp
  tor:
    container_name: app_tor
    image: peterdavehello/tor-socks-proxy:latest
    ports:
      - 9150:9150
    restart: always
    networks:
      - myapp

networks:
    myapp:
        driver: bridge


Problem using torus proxy for puppeteer in node container :

When I used local torus proxy I specified address:

'--proxy-server=socks5://127.0.0.1:9050'

Changed to:

'--proxy-server=socks5' ://tor:9050'

export const LAUNCH_PUPPETEER_OPTS = {
    args: [
        .. 
         '--proxy-server=socks5://tor:9050'
    ]
};


When starting puppeteer:

Error: net::ERR_PROXY_CONNECTION_FAILED at https://sitename.ru
at navigate (/var/www/node_modules/puppeteer/lib/FrameManager.js:120:37)
at processTicksAndRejections (internal/process/task_queues.js :86:5)
-- ASYNC --
at Frame. (/var/www/node_modules/puppeteer/lib/helper.js:111:15)
at Page.goto (/var/www/node_modules/puppeteer/lib/Page.js:672:49)
at Page. (/var/www/node_modules/puppeteer/lib/helper.js:112:23)
at PuppeteerHandler._callee2$ (/var/www/helpers/puppeteer.js:69:19)
at tryCatch (/var/www/node_modules /regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (/var/www/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype.(anonymous function) [as next] (/var/www/node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (/var/www/helpers/puppeteer.js:12:103 )
at _next (/var/www/helpers/puppeteer.js:14:194)
at processTicksAndRejections (internal/process/task_queues.js:86:5) The

following command executes locally:

curl --socks5-hostname 127.0.0.1:9150 https://ipinfo.tw/ip


62.102.148.68

From under the tor container too:

docker exec -i -t 5bdddac72709 curl --socks5-hostname 127.0.0.1:9150 https://ipinfo.tw/ip

89.144.12.17
From under the node container, similarly:
docker exec -it 03c2c7be89f8 curl --socks5-hostname tor:9150 https://ipinfo.tw/ip

166.70.207.2

Please tell me, what is the jamb here - in the port or in the host?

I also tried to install tor in the node container and configure it as follows:

'--proxy-server=socks5://127.0.0.1:9050'

The result has not changed.

Maybe in addition to curl , you need to install additional utilities into the container with node ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-02-16
@EVOSandru6

you have different ports everywhere. somewhere 9050, somewhere 9150.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question