Welcome! Log In Create A New Profile

Advanced

How to configure nginx to work with PhantomJS

Posted by waf04 
How to configure nginx to work with PhantomJS
December 29, 2013 05:12PM
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!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 77
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready