Node Prerender / PhantomJS + http-proxy does not work with websocket

I wrote a reverse proxy for my website that will serve as a load balancer. I wrote it using Node using nodejitsu hppt-proxy. My site is an AngularJS application that uses a connection to a web server to retrieve data from a server. Http-server is a node express application. Everything is working fine.

My problems started when I looked at how Google indexed my site. I could not get Google to see my content. All I could see was an index.html file with no view. So I decided to use node Prerender and display the html for the Googlebot on the server side.

The problem is that I cannot connect the web connection from Prerender / PhantomJS to my proxy. When I use curl to send a proxy request with a URL ending in "? _Escaped_fragment =" as a bot gateway, I see that the proxy sends a request to my http server, which in turn sends it to Prerender . I can see from the Prerender / PhantomJS console that my Angular application is working fine and trying to open a connection to a web server. This request finds its path to my proxy, and the proxy recognizes it as a connection update event. But for some reason, the proxy server is not working. I don't get anything on my http server. All other things are loaded with a fine (index.html, static resources), but the HTTP server does not receive a request to connect to the web server.

Any idea on what causes the problem or how to debug it? Is there a known issue with the http-proxy module and websites?

When I use curl to send a request with a URL ending in "? _Escaped_fragment =" directly to my Express.js http server port, it works, but again a request sent to the proxy on port 80 causes everything to hanging and Prerender / PhantomJS timeout. There are no errors, but everything just freezes.

I registered requests for websocket in my proxy server and looked at them for an hour trying to compare websocket requests that work (access to my Angular app from Chrome) with those that didn't, i.e. Prerender / PhantomJS Request. I did not see anything obvious, but this does not mean that there is nothing. I really do not understand the properties of these queries.

. - "proxy.js", "-http-" - "server.js", - - "websockets.js".

. ...

+4

Source: https://habr.com/ru/post/1623722/


All Articles