Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
server {
listen 80;
listen [::]:80;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri @prerender;
}
location @prerender {
set $prerender 0;
if ($http_user_agent ~* "googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator") {
set $prerender 1;
}
if ($args ~ "_escaped_fragment_") {
set $prerender 1;
}
if ($http_user_agent ~ "Prerender") {
set $prerender 0;
}
if ($uri ~* "\.(js|css|xml|less|png|jpg|jpeg|gif|pdf|doc|txt|ico|rss|zip|mp3|rar|exe|wmv|doc|avi|ppt|mpg|mpeg|tif|wav|mov|psd|ai|xls|mp4|m4a|swf|dat|dmg|iso|flv|m4v|torrent|ttf|woff|svg|eot)") {
set $prerender 0;
}
resolver kube-dns.kube-system.svc.cluster.local valid=5s;
if ($prerender = 1) {
set $prerender "rendertron";
# rewrite .* /$scheme://$host$request_uri? break;
proxy_pass http://$prerender.default.svc.cluster.local/render/$scheme://$host$request_uri?wc-inject-shadydom=true;
}
if ($prerender = 0) {
rewrite .* /index.html break;
}
}
}
@nd093

This comment has been minimized.

Copy link

@nd093 nd093 commented Jul 29, 2019

@justindavies
great configurations!
This helped me a lot to implement rendertron with nginx server.

But additionally now I am trying to create a log file only for errors generated by rendertron.
Any suggestion how can I implement it ?

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment