Using Passenger with Prerender.io

71 views
Skip to first unread message

Paolo Memoli

unread,
Apr 22, 2015, 6:32:56 AM4/22/15
to phusion-...@googlegroups.com
Hi, has anyone had any experience using passenger with prerender?

Prerender's default nginx configs dont play nice with passenger:

https://gist.github.com/thoop/8165802

eg:

server {
    listen 80;
    server_name example.com;
 
    root   /path/to/your/root;
    index  index.html;
 
    location / {
        try_files $uri @prerender;
    }
 
    location @prerender {
        #proxy_set_header X-Prerender-Token YOUR_TOKEN;
       
        set $prerender 0;
        if ($http_user_agent ~* "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)") {
            set $prerender 0;
        }
       
        #resolve using Google's DNS server to force DNS resolution and prevent caching of IPs
        resolver 8.8.8.8;
 
        if ($prerender = 1) {
           
            #setting prerender as a variable forces DNS resolution since nginx caches IPs and doesnt play well with load balancing
            set $prerender "service.prerender.io";
            rewrite .* /$scheme://$host$request_uri? break;
            proxy_pass http://$prerender;
        }
        if ($prerender = 0) {
            rewrite .* /index.html break;
        }
    }
}

anyone got an example work nginx config with passenger we can look at?

Thanks

Hongli Lai

unread,
Apr 22, 2015, 8:31:44 AM4/22/15
to phusion-passenger
What do you mean with "don't play nice"? What is the expected behavior
and what is the actual behavior?
> --
> You received this message because you are subscribed to the Google Groups
> "Phusion Passenger Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to phusion-passen...@googlegroups.com.
> To post to this group, send email to phusion-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/phusion-passenger.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/phusion-passenger/07c17334-b84e-423f-b012-4f9bdd4002db%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Phusion | Web Application deployment, scaling, and monitoring solutions

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

Paolo Memoli

unread,
Apr 22, 2015, 8:57:45 AM4/22/15
to phusion-...@googlegroups.com, hon...@phusion.nl
As in, does someone have an example nginx.conf which combines prerender's sample nginx config with passenger's nginx conf?

Using 'passenger_enabled on;' writes alot of the nginx config, prerender's service only works by using providing middleware via an nginx config, and I'm unsure how the two can be combined
Reply all
Reply to author
Forward
0 new messages