mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-12-05 17:18:19 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e518d7267 | ||
|
|
3005ba3629 | ||
|
|
176c69d1e8 | ||
|
|
7a1cf7dd80 | ||
|
|
456dfc222e | ||
|
|
23fde49f2b | ||
|
|
78daf24bc3 | ||
|
|
47c83ded58 |
@@ -5,9 +5,9 @@ ARG TARGETPLATFORM
|
|||||||
ARG BUILDPLATFORM
|
ARG BUILDPLATFORM
|
||||||
RUN printf "I am running on ${BUILDPLATFORM:-linux/amd64}, building for ${TARGETPLATFORM:-linux/amd64}\n$(uname -a)\n"
|
RUN printf "I am running on ${BUILDPLATFORM:-linux/amd64}, building for ${TARGETPLATFORM:-linux/amd64}\n$(uname -a)\n"
|
||||||
|
|
||||||
# Install the web browser (package firefox is available too)
|
# Install the web browser (package firefox-esr is available too)
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk add --no-cache firefox-esr dumb-init && \
|
apk add --no-cache firefox dumb-init && \
|
||||||
rm -Rf /var/cache
|
rm -Rf /var/cache
|
||||||
|
|
||||||
# Copy FlareSolverr code
|
# Copy FlareSolverr code
|
||||||
@@ -28,7 +28,7 @@ RUN npm install && \
|
|||||||
|
|
||||||
EXPOSE 8191
|
EXPOSE 8191
|
||||||
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
||||||
CMD ["npm", "start"]
|
CMD ["node", "./dist/server.js"]
|
||||||
|
|
||||||
# docker build -t flaresolverr:custom .
|
# docker build -t flaresolverr:custom .
|
||||||
# docker run -p 8191:8191 -e LOG_LEVEL=debug flaresolverr:custom
|
# docker run -p 8191:8191 -e LOG_LEVEL=debug flaresolverr:custom
|
||||||
|
|||||||
@@ -221,6 +221,7 @@ LOG_HTML | false | Only for debugging. If `true` all HTML that passes through th
|
|||||||
CAPTCHA_SOLVER | none | Captcha solving method. It is used when a captcha is encountered. See the Captcha Solvers section.
|
CAPTCHA_SOLVER | none | Captcha solving method. It is used when a captcha is encountered. See the Captcha Solvers section.
|
||||||
TZ | UTC | Timezone used in the logs and the web browser. Example: `TZ=Europe/London`.
|
TZ | UTC | Timezone used in the logs and the web browser. Example: `TZ=Europe/London`.
|
||||||
HEADLESS | true | Only for debugging. To run the web browser in headless mode or visible.
|
HEADLESS | true | Only for debugging. To run the web browser in headless mode or visible.
|
||||||
|
BROWSER_TIMEOUT | 30000 | If you are experiencing errors/timeouts because your system is slow, you can try to increase this value. Remember to increase the `maxTimeout` parameter too.
|
||||||
PORT | 8191 | Listening port. You don't need to change this if you are running on Docker.
|
PORT | 8191 | Listening port. You don't need to change this if you are running on Docker.
|
||||||
HOST | 0.0.0.0 | Listening interface. You don't need to change this if you are running on Docker.
|
HOST | 0.0.0.0 | Listening interface. You don't need to change this if you are running on Docker.
|
||||||
|
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "flaresolverr",
|
"name": "flaresolverr",
|
||||||
"version": "2.0.0",
|
"version": "2.0.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "flaresolverr",
|
"name": "flaresolverr",
|
||||||
"version": "2.0.0",
|
"version": "2.0.2",
|
||||||
"description": "Proxy server to bypass Cloudflare protection.",
|
"description": "Proxy server to bypass Cloudflare protection.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./dist/server.js",
|
"start": "node ./dist/server.js",
|
||||||
|
|||||||
@@ -46,4 +46,13 @@ testWebBrowserInstallation().then(() => {
|
|||||||
app.listen(serverPort, serverHost, () => {
|
app.listen(serverPort, serverHost, () => {
|
||||||
log.info(`Listening on http://${serverHost}:${serverPort}`);
|
log.info(`Listening on http://${serverHost}:${serverPort}`);
|
||||||
})
|
})
|
||||||
|
}).catch(function(e) {
|
||||||
|
log.error(e);
|
||||||
|
const msg: string = "" + e;
|
||||||
|
if (msg.includes('while trying to connect to the browser!')) {
|
||||||
|
log.error(`It seems that the system is too slow to run FlareSolverr.
|
||||||
|
If you are running with Docker, try to remove CPU limits in the container.
|
||||||
|
If not, try setting the 'BROWSER_TIMEOUT' environment variable and the 'maxTimeout' parameter to higher values.`);
|
||||||
|
}
|
||||||
|
process.exit(1);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import {SetCookie, Browser} from 'puppeteer'
|
|||||||
import log from './log'
|
import log from './log'
|
||||||
import {Proxy} from "../controllers/v1";
|
import {Proxy} from "../controllers/v1";
|
||||||
|
|
||||||
|
const os = require('os');
|
||||||
|
const fs = require('fs');
|
||||||
const puppeteer = require('puppeteer');
|
const puppeteer = require('puppeteer');
|
||||||
|
|
||||||
export interface SessionsCacheItem {
|
export interface SessionsCacheItem {
|
||||||
@@ -45,12 +47,15 @@ function buildExtraPrefsFirefox(proxy: Proxy): object {
|
|||||||
"startup.homepage_welcome_url.additional": "",
|
"startup.homepage_welcome_url.additional": "",
|
||||||
|
|
||||||
// Disable images to speed up load
|
// Disable images to speed up load
|
||||||
"permissions.default.image": 2
|
"permissions.default.image": 2,
|
||||||
|
|
||||||
|
// Limit content processes to 1
|
||||||
|
"dom.ipc.processCount": 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// proxy.url format => http://<host>:<port>
|
// proxy.url format => http://<host>:<port>
|
||||||
if (proxy && proxy.url) {
|
if (proxy && proxy.url) {
|
||||||
const [host, portStr] = proxy.url.replace(/https?:\/\//g, '').split(':');
|
const [host, portStr] = proxy.url.replace(/.+:\/\//g, '').split(':');
|
||||||
const port = parseInt(portStr);
|
const port = parseInt(portStr);
|
||||||
|
|
||||||
const proxyPrefs = {
|
const proxyPrefs = {
|
||||||
@@ -62,6 +67,7 @@ function buildExtraPrefsFirefox(proxy: Proxy): object {
|
|||||||
"network.proxy.share_proxy_settings": true,
|
"network.proxy.share_proxy_settings": true,
|
||||||
"network.proxy.socks": host,
|
"network.proxy.socks": host,
|
||||||
"network.proxy.socks_port": port,
|
"network.proxy.socks_port": port,
|
||||||
|
"network.proxy.socks_remote_dns": true,
|
||||||
"network.proxy.ssl": host,
|
"network.proxy.ssl": host,
|
||||||
"network.proxy.ssl_port": port,
|
"network.proxy.ssl_port": port,
|
||||||
"network.proxy.type": 1
|
"network.proxy.type": 1
|
||||||
@@ -80,6 +86,13 @@ export function getUserAgent() {
|
|||||||
|
|
||||||
export async function testWebBrowserInstallation(): Promise<void> {
|
export async function testWebBrowserInstallation(): Promise<void> {
|
||||||
log.info("Testing web browser installation...")
|
log.info("Testing web browser installation...")
|
||||||
|
|
||||||
|
// check user home dir. this dir will be used by Firefox
|
||||||
|
const homeDir = os.homedir();
|
||||||
|
fs.accessSync(homeDir, fs.constants.F_OK | fs.constants.R_OK | fs.constants.W_OK | fs.constants.X_OK);
|
||||||
|
log.debug("FlareSolverr user home directory is OK: " + homeDir)
|
||||||
|
|
||||||
|
// test web browser
|
||||||
const session = await create(null, {
|
const session = await create(null, {
|
||||||
oneTimeSession: true
|
oneTimeSession: true
|
||||||
})
|
})
|
||||||
@@ -107,6 +120,7 @@ export async function create(session: string, options: SessionCreateOptions): Pr
|
|||||||
const puppeteerOptions: any = {
|
const puppeteerOptions: any = {
|
||||||
product: 'firefox',
|
product: 'firefox',
|
||||||
headless: process.env.HEADLESS !== 'false',
|
headless: process.env.HEADLESS !== 'false',
|
||||||
|
timeout: process.env.BROWSER_TIMEOUT || 30000
|
||||||
}
|
}
|
||||||
|
|
||||||
puppeteerOptions.extraPrefsFirefox = buildExtraPrefsFirefox(options.proxy)
|
puppeteerOptions.extraPrefsFirefox = buildExtraPrefsFirefox(options.proxy)
|
||||||
|
|||||||
Reference in New Issue
Block a user