Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

How to configure nginx to work with PhantomJS

$
0
0
Hi Guys, I'm just getting started with nginx. I'm hosting an angular app on aws ec2 and I'm using phantomjs to serve a rendered html page for SEO purposes.

When I set up nginx and modify the config, requests to http://mysite.com/#!/home work perfectly.

However, when i do http://mysite.com/?_escaped_fragment_=/home I get a 501 error. The search engines would turn the #! into ?_escaped_fragment_= so I need to configure nginx to route to the phantomjs server when a request comes in.

Here is my sample config file which does not route properly right now.

How can I configure this so that it routes to the phantomjs server listening on 8888 (the tutorial says to proxy to the phantom instance here)?

server {

location / {

if ($args ~ _escaped_fragment_) {
proxy_pass http://localhost:8888;
break;
}
root /var/www/html/miwebapp/client/app;
}
}


Here is the command I use to start my phantom server:

sudo phantomjs --disk-cache=no angular-seo-server.js 8888 http://localhost:8000/home

Thanks!

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>