Node Prerender Working with the first page load - Error 500 after subsequent loads

You can make sure that it is. Click the link, let it download, then update: http://www.justinmcmahon.com/?_escaped_fragment_=

Probably significant: my application runs in the docker container on port 3000, as does the prerender server (on port 9000), both of which work behind the official Dginx docker sample.

Significance is also possible: the top-level domain redirects .htaccess to the www subdomain, which points to elastic AWS IP. I'm not very smart at this yet, so the best way I came up with is to show things in the right direction.

.htaccess redirect

RewriteEngine on 
RewriteRule ^(.*)$ http://www.justinmcmahon.com/$1 [R=301,L] 

Nginx docker-compose.yml:

nginx:

 build: .
 container_name: Nginx
 hostname: nginx
 restart: always

 environment:
   - DEFAULT_HOST=www.justinmcmahon.com

 volumes:
   - /var/run/docker.sock:/tmp/docker.sock:ro

 ports:
   - 80:80
   - 443:443
   - 5984:5984 

Prerender dockerfile

FROM node:5.2.0
ENV NPM_CONFIG_PRODUCTION=true
ENV NODE_ENV=production
COPY dist /app
WORKDIR /app
RUN npm install
EXPOSE 9000
CMD ["node", "server"]

I have the following at the top of my Express configuration:

app.use(require('prerender-node').set('prerenderServiceUrl', config.PRERENDER_SERVICE_URL));

prerender 304, Express 500

+4
1

, , , , , , .

/server.js PRERENDER_NUM_WORKERS PRERENDER_NUM_ITERATIONS 1 inMemoryHtmlCache()

#!/usr/bin/env node
var prerender = require('./lib');

var server = prerender({
    workers: process.env.PRERENDER_NUM_WORKERS || 1,
    iterations: process.env.PRERENDER_NUM_ITERATIONS || 1
});


server.use(prerender.sendPrerenderHeader());
// server.use(prerender.basicAuth());
// server.use(prerender.whitelist());
server.use(prerender.blacklist());
// server.use(prerender.logger());
server.use(prerender.removeScriptTags());
server.use(prerender.httpHeaders());
server.use(prerender.inMemoryHtmlCache());
// server.use(prerender.s3HtmlCache());

server.start();

, , , , , .

+3

All Articles