# Proxy-Puppeteer-API

## How to install for testing ###

Requirement package: nodejs and npm

`apt-get install nodejs npm`

Cloning repo

```
user@devel1:~/pr1$ git clone https://github.com/RapidSeedbox/Proxy-Puppeteer-API
Cloning into 'Proxy-Puppeteer-API'...
Username for 'https://github.com': aleksovboban@gmail.com
Password for 'https://aleksovboban@gmail.com@github.com': 
user@devel1:~/pr1$ cd Proxy-Puppeteer-API/
user@devel1:~/pr1/Proxy-Puppeteer-API$ npm i         
```

This will install all node packages required.
After this, we proceed with:

```
user@devel1:~/pr1/Proxy-Puppeteer-API$ node main_app.js 
Listening at http://localhost:3000
```

Requests can be sent in a form:http://IP.AD.D.RES:3000/render?url=https://www.WEB_SITE_URL

## Configuration

### Environment variables

Following environment variables exist and should be set accordingly in production environment:

 - `PUPPETEER_LISTEN_PORT` - port on which the API will be listening to (`3001` means it'll listen on 0.0.0.0:3001)
 - `PUPPETEER_PROXY_HOST` - IP or hostname of the 3proxy server. Should be set as `localhost`
 if it's stored on same server as 3proxy
 - `PUPPETEER_PROXY_USER` - username for 3proxy authentication
 - `PUPPETEER_PROXY_PASS` - password for 3proxy authentication
 - `PUPPETEER_PROXY_START_PORT` - lowest port 3proxy is listening on. Highest port used is counted as
 `PUPPETEER_PROXY_START_PORT` + `PUPPETEER_BROWSER_INSTANCES`
 - `PUPPETEER_2CAPTCHA_API` - API Key for [2captcha](https://2captcha.com/) service
 - `PUPPETEER_BROWSER_INSTANCES` - how many browsers should be running
 - `PUPPETEER_NO_HEADLESS` - variable to disable headless mode, useful for testing purposes.
 In production environment it should be omitted. Variable should be set to `1` or `true` to take effect,
 falsy values are not supported
 - `PUPPETEER_NO_CAPTCHA_SOLVING` - variable to disable captcha solving, useful for testing purposes. 
 In production environment it should be omitted. Variable should be set to `1` or `true` to take effect,
 falsy values are not supported

They all have default values which are set for testing purposes, so they only need to be overwritten in production.
