42 lines
1.2 KiB
Markdown
42 lines
1.2 KiB
Markdown
# chromedom
|
|
|
|
a simple proxy for rendering SPA
|
|
|
|
## how to use
|
|
|
|
### configure nginx
|
|
|
|
see also https://gist.github.com/thoop/8165802
|
|
|
|
```
|
|
location / {
|
|
try_files $uri @prerender;
|
|
}
|
|
|
|
location @prerender {
|
|
proxy_set_header Host $host;
|
|
set $prerender 0;
|
|
if ($http_user_agent ~* "googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp|$
|
|
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;
|
|
}
|
|
if ($prerender = 1) {
|
|
proxy_pass http://127.0.0.1:9292;
|
|
}
|
|
if ($prerender = 0) {
|
|
rewrite .* /index.html break;
|
|
}
|
|
}
|
|
```
|
|
|
|
### configure
|
|
|
|
documentation WIP |