<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cory O&#039;Daniel - These are just words &#187; ActionScript</title>
	<atom:link href="http://coryodaniel.com/index.php/category/software/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://coryodaniel.com</link>
	<description>Software development, thoughts, and randomness</description>
	<lastBuildDate>Thu, 17 Nov 2011 21:18:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Dealing with Adobe and Serving Socket Policy Servers via NGiNX and 10 lines of code</title>
		<link>http://coryodaniel.com/index.php/2009/06/10/dealing-with-adobe-and-serving-socket-policy-servers-via-nginx-and-10-lines-of-code/</link>
		<comments>http://coryodaniel.com/index.php/2009/06/10/dealing-with-adobe-and-serving-socket-policy-servers-via-nginx-and-10-lines-of-code/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 17:57:59 +0000</pubDate>
		<dc:creator>Cory O'Daniel</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[adobe flash]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[goddamnadobe]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[socket policy server]]></category>

		<guid isPermaLink="false">http://blog.vokle.com/?p=238</guid>
		<description><![CDATA[Ok, I don't even know where to start, but I guess I'll start by thanking Adobe for a such a high quality product (&#60;/sarcasm&#62;).  So we are working towards our new Vokle product, dubbed Vokle Everywhere (by me, just now).
So our new product allows for embeddability of chats and to do this we use ActionScript [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, I don't even know where to start, but I guess I'll start by thanking Adobe for a such a high quality product (&lt;/sarcasm&gt;).  So we are working towards our new Vokle product, dubbed Vokle Everywhere (by me, just now).</p>
<p>So our new product allows for embeddability of chats and to do this we use ActionScript 3.  I wouldn't say that AS3 has its short comings, except of course, Flex, but from time to time we have some issues with it.  Like not being able to override the 'Accept' header in a UrlRequest and other various dumb things.  Instead we moved to a mildly liberating open source <a href="http://code.google.com/p/as3httpclientlib/" target="_blank">AS3 HTTP Client.</a></p>
<p>AS3HTTPClientLib is pretty sweet, the only thing that sort of sucked was that we needed a Socket Policy Server, and the last thing I want to do is run another server (already have nginx, merb, wowza, yadayadayada) like this <a href="http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html" target="_blank">butthole suggests</a>.</p>
<p>Instead I figured, there has to be a way to just serve the crossdomain.xml file without being a giant hassle, especially since I am already serving it over HTTP for the same domain.  So I said, frig it, I'll do it with NGiNX since NGiNX is already serving my static files.  So the upside is when my servers are running, my 'policy server' is serving, the downside is, I had to finagle it so it wasn't a pain in the ass.  The problem is that ActionScript makes a 'weird' request when its looking for a policy server, and NGiNX doesn't understand it, so it servers a 400 Bad Request, well, it turns out that you can just do it hackety-hack and send your crossdomain.xml file as the 400 Error Page.  This works because AS isn't doing an HTTP Request, so it DOESNT CARE about the HTTP Status.  Bam, NGiNX Flash Socket Policy Server in 10 lines of code.</p>
<p>To enable 'socket policy server' functionality in NGiNX simply add another 'server' directive to your nginx.conf and drop your crossdomain.xml file in whatever folder your NGiNX server is serving its statics from.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">    server <span style="color: #7a0874; font-weight: bold;">&#123;</span>
      listen <span style="color: #000000;">843</span>;
      server_name  localhost;
&nbsp;
      location <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        rewrite ^<span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>$ <span style="color: #000000; font-weight: bold;">/</span>crossdomain.xml;
      <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
      error_page <span style="color: #000000;">400</span> <span style="color: #000000; font-weight: bold;">/</span>crossdomain.xml;
&nbsp;
      location = <span style="color: #000000; font-weight: bold;">/</span>crossdomain.xml <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        root html;
      <span style="color: #7a0874; font-weight: bold;">&#125;</span>
    <span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></td></tr></table></div>

<p> </p>
<p>Sweet, start your nginx server and use the only useful thing from the Adobe blog post:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'printf &quot;&lt;policy-file-request/&gt;%c&quot;,0'</span> <span style="color: #000000; font-weight: bold;">|</span> nc 127.0.0.1 <span style="color: #000000;">843</span></pre></td></tr></table></div>

<p>And you should see your policy file.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Dealing+with+Adobe+and+Serving+Socket+Policy+Servers+via+NGiNX+and+10+lines+of+code+http://coryodaniel.com/?p=238" title="Post to Twitter"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://coryodaniel.com/index.php/2009/06/10/dealing-with-adobe-and-serving-socket-policy-servers-via-nginx-and-10-lines-of-code/&amp;title=Dealing+with+Adobe+and+Serving+Socket+Policy+Servers+via+NGiNX+and+10+lines+of+code" title="Post to Digg"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-digg-big2.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://coryodaniel.com/index.php/2009/06/10/dealing-with-adobe-and-serving-socket-policy-servers-via-nginx-and-10-lines-of-code/&amp;t=Dealing+with+Adobe+and+Serving+Socket+Policy+Servers+via+NGiNX+and+10+lines+of+code" title="Post to Facebook"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-facebook-big2.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://coryodaniel.com/index.php/2009/06/10/dealing-with-adobe-and-serving-socket-policy-servers-via-nginx-and-10-lines-of-code/&amp;title=Dealing+with+Adobe+and+Serving+Socket+Policy+Servers+via+NGiNX+and+10+lines+of+code" title="Post to Reddit"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-reddit-big2.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://coryodaniel.com/index.php/2009/06/10/dealing-with-adobe-and-serving-socket-policy-servers-via-nginx-and-10-lines-of-code/&amp;title=Dealing+with+Adobe+and+Serving+Socket+Policy+Servers+via+NGiNX+and+10+lines+of+code" title="Post to StumbleUpon"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-su-big2.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://coryodaniel.com/index.php/2009/06/10/dealing-with-adobe-and-serving-socket-policy-servers-via-nginx-and-10-lines-of-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

