forked from holin/docker-prerender
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
34 lines (30 loc) · 1023 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node
var prerender = require('prerender');
var server = prerender({
workers: process.env.PHANTOM_CLUSTER_NUM_WORKERS,
iterations: process.env.PHANTOM_WORKER_ITERATIONS || 10,
phantomBasePort: process.env.PHANTOM_CLUSTER_BASE_PORT || 12300,
messageTimeout: process.env.PHANTOM_CLUSTER_MESSAGE_TIMEOUT
});
server.use(prerender.removeScriptTags());
server.use(prerender.httpHeaders());
if ('LOGGER' in process.env) {
server.use(prerender.logger());
}
if ('BASIC_AUTH_USERNAME' in process.env && 'BASIC_AUTH_PASSWORD' in process.env) {
server.use(prerender.basicAuth());
}
if ('ALLOWED_DOMAINS' in process.env) {
server.use(prerender.whitelist());
}
if ('BLACKLISTED_DOMAINS' in process.env) {
server.use(prerender.blacklist());
}
if ('S3_BUCKET_NAME' in process.env) {
server.use(prerender.s3HtmlCache());
} else if ('REDIS_URL' in process.env) {
server.use(require('prerender-redis-cache'));
} else {
server.use(prerender.inMemoryHtmlCache());
}
server.start();