Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

docker-prerender

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docker-prerender - npm Package Compare versions

Comparing version
1.0.0
to
2.0.0
+14
-10
package.json
{
"name": "docker-prerender",
"version": "1.0.0",
"description": "Dockerfile to build the prerender container image",
"main": "server.js",
"dependencies": {
"prerender": "^4.1.0"
},
"devDependencies": {},
"version": "2.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "MIT"
"repository": {
"type": "git",
"url": "git+https://github.com/npm/deprecate-holder.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/npm/deprecate-holder/issues"
},
"homepage": "https://github.com/npm/deprecate-holder#readme"
}

@@ -1,5 +0,5 @@

[![Dependency Status](https://gemnasium.com/badges/github.com/Magnetme/prerender-docker.svg)](https://gemnasium.com/github.com/Magnetme/prerender-docker)
# Deprecated Package
A simple Docker container which run a relatively recent Prerender instance.
We use it @ [Magnet.me](https://magnet.me) to serve beautiful content to scrapers which do not understand Javascript (Facebook or Whatsapp for example).
This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.
Please contact support@npmjs.com if you have questions about this package.
FROM node:latest
MAINTAINER Magnet.me
EXPOSE 3000
RUN apt-get update \
&& apt-get install -y \
build-essential g++ flex bison gperf ruby perl \
libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev \
libpng-dev libjpeg-dev python libx11-dev libxext-dev
RUN mkdir -p /usr/src/app
RUN groupadd -r prerender && useradd -r -g prerender -d /usr/src/app prerender
RUN chown prerender:prerender /usr/src/app
USER prerender
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
CMD [ "npm", "start" ]
// Set all blacklisted headers as lowercase
var BLACKLISTED = [
'user-agent', // Prerender sets her own user agent, which we dont want to override
'host', // This is set to the host of prerender, so its wrong to forward
'accept', // Let prerender accept everything and handle it
'accept-encoding', // We dont want to forward deflate or gzip since prerender will break on those
'connection', // No sudden keepalive stuff
'accept-charset', // Prerender handles this
'content-length' // Since we are rewriting lots of the request, we let prerender recalculate this
];
module.exports = {
// Since prerender does not forward headers, this causes problems for some crawlers looking for
// e.g. localized content. This plugin ensures the headers sent to prerender are also set in
// the PhantomJS instance. Some headers may be blacklisted and will not be forwarded.
onPhantomPageCreate: function (phantom, req, res, next) {
// The following function is executed in the Phridge context, which means we do not have a
// regular closure over it. Instead this function is stringified and sent to Phridge, where
// it is executed.
function executeInsidePhantom(headers, blacklisted, resolve) {
var customHeaders = this.customHeaders || {};
for (var header in headers) {
if (headers.hasOwnProperty(header) && blacklisted.indexOf(header) === -1) {
customHeaders[header] = headers[header];
// console.debug('Forwarding header ' + header);
}
}
this.customHeaders = customHeaders;
resolve();
}
// By setting the headers as an argument here, they will be bound in the function in Phridge.
// Transformation is done using JSON.stringify and the resulting JSON object is unpacked in
// Phridge. We use a promise based approach so we can detect when phridge has set the headers,
// and we continue the middleware chain.
req.prerender.page.run(req.headers, BLACKLISTED, executeInsidePhantom
).then(function () {
next();
}).catch(function () {
res.sendStatus(statusCode);
res.end('Could not forward sent headers');
});
}
};
var prerender = require('prerender');
var forwardHeaders = require('./forwardHeaders');
var server = prerender({
workers: process.env.PRERENDER_NUM_WORKERS || 4,
iterations: process.env.PRERENDER_NUM_ITERATIONS || 25,
softIterations: process.env.PRERENDER_NUM_SOFT_ITERATIONS || 10
});
server.use(forwardHeaders);
server.use(prerender.sendPrerenderHeader());
server.use(prerender.removeScriptTags());
server.use(prerender.httpHeaders());
server.start();
function shutdown() {
console.log('Shutdown initiated');
server.exit();
// At this point prerender has started killing its phantom workers already.
// We give it 5 seconds to quickly do so, and then halt the process. This
// will ensure relatively rapid redeploys (prerender no longer accepts new
// requests at this point
setTimeout(function () {
console.log('Prerender has shut down');
process.exit();
}, 5000);
}
process.on('SIGINT', shutdown);
process.on('SIGTERM', shutdown);