Requests from PhantomJS being blocked

We have an application which generates Images and PDFs from rendered HTML using PhantomJS. This is running on an nginx server.

The HTML files are saved on the same server as the application and these are requested by the headless browser inside PhantomJS.

This set up was all working perfectly for about 3 weeks when suddenly the Images and PDFs started coming back blank (black background with small blue squares where the images should be).

At first I thought the issue was related to internal DNS - the HTML file is passed to PhantomJS as a path but all the css and images are loaded in to the HTML over URLS. If I changed these URLs to point to another domain (not Digital Ocean) I could get the PDF to render. If I moved all the CSS to be inline in the HTML file it would also render (albeit without images), but no http request made by PhantomJS to the Digital Ocean server seemed to resolve.

I then tried to load one of the rendered HTML files stored on the Digital Ocean server into a PhantomJS set up hosted on a different server (again, not Digital Ocean). In this case the HTML was passed as a URL and this initial request was blocked - the PhantomJS process just hung.

It certainly seems as though Digital Ocean has started blocking all requests from PhantomJS. Perhaps these requests are being considered malicious and have triggered some security measure.

I saw this post which referred to something similar:

Can anyone suggest anyway to test the theory and hopefully get these requests unblocked?

Many thanks, Malcolm


… further to the above - I replaced all local URLs with paths in the HTML before passing it to PhantomJS and the resulting images and PDFs were correctly rendered.

This further suggests that the issue is related to DigitalOcean blocking http requests from PhantomJS.

It would be great if someone from @digitalOcean could respond to this. What might have changed to mean these requests suddenly started getting blocked.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I have no specific solution here but I have had problems in the past with web page renderers when underlying package dependencies are not installed on the operating system. Is it possible your underlying operating system has been updated and the required dependencies (or versions) have been changed?