Skip to content
A simple Flash Policy File Server for node
Latest commit 15a7614 Jul 3, 2012 @3rd-Eden Merge pull request #2 from mweibel/master
Fix typos in README
Failed to load latest commit information.
examples Fixing a few implementation bugs May 30, 2011
lib 0.0.5 Oct 28, 2011
LICENSE Added new files May 31, 2011
index.js Add make file and index May 26, 2011
package.json updated tags Oct 30, 2011


It basically allows you to allow or disallow Flash Player sockets from accessing your site.


npm install policyfile


The server is based on the regular and know net and http server patterns. So it you can just listen for all the events that a net based server emits etc. But there is one extra event, the connect_failed event. This event is triggered when we are unable to listen on the supplied port number.


Creates a new server instance and accepts 2 optional arguments:

  • options Object Options to configure the server instance
    • log Boolean Enable logging to STDOUT and STDERR (defaults to true)
  • origins Array An Array of origins that are allowed by the server (defaults to :)
var pf = require('policyfile').createServer();



Start listening on the server and it takes 3 optional arguments

  • port Number On which port number should we listen? (defaults to 843, which is the first port number the FlashPlayer checks)
  • server Server A http server, if we are unable to accept requests or run the server we can also answer the policy requests inline over the supplied HTTP server.
  • callback Function A callback function that is called when listening to the server was successful.
var pf = require('policyfile').createServer();

pf.listen(1337, function(){
  console.log(':3 yay')

Changing port numbers can be handy if you do not want to run your server as root and have port 843 forward to a non root port number (aka a number above 1024).

var pf = require('policyfile').createServer()
  , http = require('http');

server = http.createServer(function(q,r){r.writeHead(200);r.end('hello world')});

pf.listen(1337, server, function(){
  console.log(':3 yay')

Support for serving inline requests over a existing HTTP connection as the FlashPlayer will first check port 843, but if it's unable to get a response there it will send a policy file request over port 80, which is usually your http server.


Adds more origins to the policy file you can add as many arguments as you like.

var pf = require('policyfile').createServer(['']);

pf.add('', ''); // now has 3 origins


Removes added origins from the policy file - you can add as many arguments as you like.

var pf = require('policyfile').createServer(['', '']);

pf.remove(''); // only contains the :80 version now


Shuts down the server

var pf = require('policyfile').createServer();

pf.close(); // OH NVM.



See for examples


MIT see LICENSE file in the repository

Something went wrong with that request. Please try again.