<?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>eXpand yOur cReativity &#187; Amazon EC2</title>
	<atom:link href="http://blog.bhushangahire.net/category/amazon-ec2/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bhushangahire.net</link>
	<description>by Bhushan G Ahire</description>
	<lastBuildDate>Mon, 26 Jul 2010 10:25:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Windows Firewall and non-secure FTP traffic Rule for firewall</title>
		<link>http://blog.bhushangahire.net/2010/05/13/windows-firewall-and-non-secure-ftp-traffic/</link>
		<comments>http://blog.bhushangahire.net/2010/05/13/windows-firewall-and-non-secure-ftp-traffic/#comments</comments>
		<pubDate>Thu, 13 May 2010 05:59:21 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[2008]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=179</guid>
		<description><![CDATA[
Windows firewall can be configured from command line using netsh command. 2 simple steps are required to setup Windows Firewall to allow non-secure FTP traffic
 
1) Open port 21 on the firewall
netsh advfirewall firewall add rule name=&#8221;FTP (no SSL)&#8221; action=allow protocol=TCP dir=in localport=21
2) Activate firewall application filter for FTP (aka Stateful FTP) that will dynamically [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F05%2F13%2Fwindows-firewall-and-non-secure-ftp-traffic%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<p><strong>Windows firewall can be configured from command line using netsh command. 2 simple steps are required to setup Windows Firewall to allow non-secure FTP traffic</strong></p>
<p><span style="font-family: Arial; font-size: x-small;"> </span></p>
<p align="left"><strong>1)</strong> Open port 21 on the firewall</p>
<p><em><span style="color: #4f6228; font-size: x-small;"><strong>netsh advfirewall firewall add rule name=&#8221;FTP (no SSL)&#8221; action=allow protocol=TCP dir=in localport=21</strong></span></em></p>
<p><span style="font-size: x-small;"><strong>2)</strong> Activate firewall application filter for FTP (aka Stateful FTP) that will dynamically open ports for data connections</span></p>
<p><em><span style="color: #4f6228; font-size: x-small;"><strong>netsh advfirewall set global StatefulFtp enable</strong></span></em></p>
<p><em>Hope this information is helpful for you&#8230;.</em></p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2010/05/13/windows-firewall-and-non-secure-ftp-traffic/&amp;title=Windows+Firewall+and+non-secure+FTP+traffic+Rule+for+firewall" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2010/05/13/windows-firewall-and-non-secure-ftp-traffic/&amp;title=Windows+Firewall+and+non-secure+FTP+traffic+Rule+for+firewall" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2010/05/13/windows-firewall-and-non-secure-ftp-traffic/&amp;title=Windows+Firewall+and+non-secure+FTP+traffic+Rule+for+firewall" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2010/05/13/windows-firewall-and-non-secure-ftp-traffic/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2010/05/13/windows-firewall-and-non-secure-ftp-traffic/&amp;t=Windows+Firewall+and+non-secure+FTP+traffic+Rule+for+firewall" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Windows+Firewall+and+non-secure+FTP+traffic+Rule+for+firewall+-+http://blog.bhushangahire.net/2010/05/13/windows-firewall-and-non-secure-ftp-traffic/+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2010/05/13/windows-firewall-and-non-secure-ftp-traffic/&amp;title=Windows+Firewall+and+non-secure+FTP+traffic+Rule+for+firewall&amp;summary=Windows%20firewall%20can%20be%20configured%20from%20command%20line%20using%20netsh%20command.%202%20simple%20steps%20are%20required%20to%20setup%20Windows%20Firewall%20to%20allow%20non-secure%20FTP%20traffic%0D%0A%0D%0A%20%0D%0A1%29%20Open%20port%2021%20on%20the%20firewall%0D%0Anetsh%20advfirewall%20firewall%20add%20rule%20name%3D%22FTP%20%28no%20SSL%29%22%20action%3Dallow%20protocol%3DTCP%20dir%3Din%20localport%3D21&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F05%2F13%2Fwindows-firewall-and-non-secure-ftp-traffic%2F&amp;t=Windows+Firewall+and+non-secure+FTP+traffic+Rule+for+firewall" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/05/13/windows-firewall-and-non-secure-ftp-traffic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How Do I Enable remote access to PostgreSQL database server?</title>
		<link>http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/</link>
		<comments>http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/#comments</comments>
		<pubDate>Tue, 11 May 2010 12:11:22 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=177</guid>
		<description><![CDATA[



By default, PostgreSQL database server remote access disabled for security reasons. However, some time you need to provide the remote access to database server from home computer or from web server.
Step # 1: Login over ssh if server is outside your IDC
Login over ssh to remote PostgreSQL  database server:
$ ssh user@remote.pgsql.server.com
Step # 2: Enable [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F05%2F11%2Fhow-do-i-enable-remote-access-to-postgresql-database-server%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<div class="format_text entry-content">
<div style="float: right; margin-top: 0px; margin-left: 5px;"><a title="See all Postgresql related tips/articles" href="http://www.cyberciti.biz/tips/category/postgresql/"><br />
<img src="http://figs.cyberciti.biz/3rdparty/pgsql-logo.png" border="0" alt="" /></a></div>
<p>By default, PostgreSQL database server remote access disabled for security reasons. However, some time you need to provide the remote access to database server from home computer or from web server.</p>
<h2>Step # 1: Login over ssh if server is outside your IDC</h2>
<p>Login over ssh to remote PostgreSQL  database server:</p>
<p><code>$ ssh user@remote.pgsql.server.com</code></p>
<h2>Step # 2: Enable client authentication</h2>
<p>Once connected, you need edit the PostgreSQL configuration file, edit the PostgreSQL configuration file <strong>/var/lib/pgsql/data/pg_hba.conf</strong> (or <strong>/etc/postgresql/8.2/main/pg_hba.conf</strong> for latest 8.2 version) using a text editor such as vi.</p>
<p>Login as postgres user using su / sudo command, enter:</p>
<p><code>$ su - postgres</code></p>
<p>Edit the file:</p>
<p><code>$ vi /var/lib/pgsql/data/pg_hba.conf</code></p>
<p>OR</p>
<p><code>$ vi /etc/postgresql/8.2/main/pg_hba.conf</code></p>
<p>Append the following configuration lines to give access to 10.10.29.0/24 network:</p>
<p><code>host all all 10.10.29.0/24 trust</code></p>
<p>Save and close the file.  Make sure you replace 10.10.29.0/24 with  actual network IP address range of the clients system in your own network.</p>
<h2>Step # 2: Enable networking for PostgreSQL</h2>
<p>You need to enable TCP / IP networking. Use either step #3 or #3a as per your PostgreSQL database server version.</p>
<h2>Step # 3: Allow TCP/IP socket</h2>
<p>If you are using <strong>PostgreSQL version 8.x or newer</strong> use the following instructions or skip to <a href="#3a">Step # 3a</a> for older version (7.x or older).</p>
<p>You need to open PostgreSQL configuration file /var/lib/pgsql/data/postgresql.conf or /etc/postgresql/8.2/main/postgresql.conf.</p>
<p><code># vi /etc/postgresql/8.2/main/postgresql.conf</code></p>
<p>OR</p>
<p><code># vi /var/lib/pgsql/data/postgresql.conf </code></p>
<p>Find configuration line that read as follows:</p>
<p><code>listen_addresses='localhost'</code></p>
<p>Next set IP address(es) to listen on; you can use comma-separated list of addresses; defaults to &#8216;localhost&#8217;, and &#8216;*&#8217; is all ip address:</p>
<p><code>listen_addresses='*'</code></p>
<p>Or just bind to 202.54.1.2 and 202.54.1.3 IP address</p>
<p><code>listen_addresses='202.54.1.2 202.54.1.3'</code></p>
<p>Save and close the file. Skip to <a href="#4">step # 4</a>.</p>
<h3>Step #3a &#8211; Information for old version 7.x  or older</h3>
<p>Following configuration only required for <strong>PostgreSQL version 7.x or older</strong>. Open config file, enter:</p>
<p><code># vi /var/lib/pgsql/data/postgresql.conf </code></p>
<p>Bind and open TCP/IP port by setting tcpip_socket to true.  Set / modify tcpip_socket to true:</p>
<p><code>tcpip_socket = true</code></p>
<p>Save and close the file.</p>
<h2>Step # 4: Restart PostgreSQL Server</h2>
<p>Type the following command:</p>
<p><code># /etc/init.d/postgresql restart</code></p>
<h2>Step # 5: Iptables firewall rules</h2>
<p>Make sure iptables is not blocking communication, <a href="http://www.cyberciti.biz/tips/howto-iptables-postgresql-open-port.html">open port 5432</a> (append rules to your iptables scripts or file <a href="http://www.cyberciti.biz/faq/howto-block-ipaddress-of-spammers-with-firewall/">/etc/sysconfig/iptables</a>):</p>
<pre>iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d 20.04.23.22  --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s 20.04.23.22 --sport 5432 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT</pre>
<p>Restart firewall:</p>
<p><code># /etc/init.d/iptables restart</code></p>
<h2>Step # 6: Test your setup</h2>
<p>Use psql command from client system. Connect to remote server using IP address 20.04.23.22 and login using postgres username and testdatabase database, enter:</p>
<p><code>$ psql -h 20.04.23.22 -U postgres -d testdatabase</code></p>
</div>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/&amp;title=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/&amp;title=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/&amp;title=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/&amp;t=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F+-+http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/&amp;title=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F&amp;summary=%0D%0A%0D%0A%0D%0ABy%20default%2C%20PostgreSQL%20database%20server%20remote%20access%20disabled%20for%20security%20reasons.%20However%2C%20some%20time%20you%20need%20to%20provide%20the%20remote%20access%20to%20database%20server%20from%20home%20computer%20or%20from%20web%20server.%0D%0AStep%20%23%201%3A%20Login%20over%20ssh%20if%20server%20is%20outside%20your%20IDC%0D%0ALogin%20over%20ssh%20to%20remote%20PostgreSQL%20%20d&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F05%2F11%2Fhow-do-i-enable-remote-access-to-postgresql-database-server%2F&amp;t=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paypal Instant Payment Notification in Rails with Active Merchant</title>
		<link>http://blog.bhushangahire.net/2009/08/05/paypal-instant-payment-notification-in-rails-with-active-merchant/</link>
		<comments>http://blog.bhushangahire.net/2009/08/05/paypal-instant-payment-notification-in-rails-with-active-merchant/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 08:56:04 +0000</pubDate>
		<dc:creator>Bhushan Ahire</dc:creator>
				<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[paypal]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[active merchant]]></category>
		<category><![CDATA[payment]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=139</guid>
		<description><![CDATA[
Active Merchant makes it extremely simple to use Paypal IPN. Here is a simple guide for getting IPN up and running.
Sign up for a Paypal sandbox account
Paypal provides a sandbox environment that mimics their production environment, with the exception that it doesn’t actually process the transactions.  This is extremely useful for development and testing. [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2009%2F08%2F05%2Fpaypal-instant-payment-notification-in-rails-with-active-merchant%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<p><a href="http://home.leetsoft.com/am/">Active Merchant</a> makes it extremely simple to use Paypal <abbr title="Instant Payment Notification"><span class="caps">IPN</span></abbr>. Here is a simple guide for getting <span class="caps">IPN</span> up and running.</p>
<h3>Sign up for a <a href="https://developer.paypal.com/">Paypal sandbox account</a></h3>
<p>Paypal provides a sandbox environment that mimics their production environment, with the exception that it doesn’t actually process the transactions.  This is extremely useful for development and testing.  It allows you to create multiple fake accounts and generate bank accounts and credit cards. More information can be found on Paypal’s <a href="http://www.paypal.com/cgi-bin/webscr?cmd=_ipn-test-about-outside">Testing Instant Payment Notification</a> page.</p>
<p>Unfortunately, I’ve signed up for two different developer accounts and I’ve had trouble logging in with both of them.  I’ve tried resetting my password, but I still can’t log in.  Fortunately, I already have my sandbox accounts set up and don’t really have a need for it (except to write this guide).</p>
<h3>Create a Personal account and add a credit card</h3>
<p>After you sign up for your developer account, create a personal sandbox account and add a credit card.</p>
<h3>Create a Business account and add a checking</h3>
<p>Next, create a business sandbox account and add a checking account.</p>
<h3>Install the money gem</h3>
<pre>sudo gem install money</pre>
<h3>Install the Active Merchant plugin</h3>
<pre>script/plugin install http://activemerchant.googlecode.com/svn/trunk/active_merchant</pre>
<h3>Create a form that submits to Paypal</h3>
<p>Include <code>ActiveMerchant::Billing::Integrations</code> in a controller to add Active Merchant’s helpers.</p>
<pre><code class="ruby"><span class="keywords">class</span> <span class="constants">PaymentsController</span> &lt; <span class="constants">ApplicationController</span>
  include <span class="constants">ActiveMerchant</span>:<span class="symbol">:Billing</span>:<span class="symbol">:Integrations</span>

  <span class="keywords">def</span> create
    <span class="instance">@enrollment</span> = current_user<span class="method">.enrollments</span><span class="method">.find</span><span class="brackets">(</span>params<span class="brackets">[</span><span class="symbol">:id</span><span class="brackets">]</span><span class="brackets">)</span>
  <span class="keywords">end</span>
<span class="keywords">end</span></code></pre>
<p>In the view, use <code>payment_service_for</code> to create a form that submits to Paypal to process the payment.</p>
<pre><code class="erb"><span class="tag">&lt;%</span> payment_service_for <span class="instance">@enrollment</span><span class="method">.id</span>, <span class="constants">PAYPAL_ACCOUNT</span>,
        <span class="symbol">:amount</span> =&gt; <span class="instance">@enrollment</span><span class="method">.course</span><span class="method">.deposit</span>, <span class="symbol">:currency</span> =&gt; <span class="string">'USD'</span>,
        <span class="symbol">:service</span> =&gt; <span class="symbol">:paypal</span> <span class="keywords">do</span> |service|

    service<span class="method">.customer</span> <span class="symbol">:first_name</span> =&gt; <span class="instance">@enrollment</span><span class="method">.student</span><span class="method">.first_name</span>,
        <span class="symbol">:last_name</span> =&gt; <span class="instance">@enrollment</span><span class="method">.student</span><span class="method">.last_name</span>,
        <span class="symbol">:phone</span> =&gt; <span class="instance">@enrollment</span><span class="method">.student</span><span class="method">.phone</span>,
        <span class="symbol">:email</span> =&gt; <span class="instance">@enrollment</span><span class="method">.student</span><span class="method">.email</span>
    service<span class="method">.billing_address</span> <span class="symbol">:city</span> =&gt; <span class="instance">@enrollment</span><span class="method">.student</span><span class="method">.city</span>,
        <span class="symbol">:address1</span> =&gt; <span class="instance">@enrollment</span><span class="method">.student</span><span class="method">.street</span>,
        <span class="symbol">:state</span> =&gt; <span class="instance">@enrollment</span><span class="method">.student</span><span class="method">.state</span>,
        <span class="symbol">:country</span> =&gt; <span class="string">'USA'</span>,
        <span class="symbol">:zip</span> =&gt; <span class="instance">@enrollment</span><span class="method">.student</span><span class="method">.zip</span>
    service<span class="method">.item_name</span> <span class="string">"#{@enrollment.course.program} Deposit"</span>
    service<span class="method">.invoice</span> <span class="instance">@enrollment</span><span class="method">.invoice</span><span class="method">.id</span>
    service<span class="method">.tax</span> <span class="string">'0.00'</span>

    service<span class="method">.notify_url</span> url_for<span class="brackets">(</span><span class="symbol"> <img src='http://blog.bhushangahire.net/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nly_path</span> =&gt; <span class="constants">false</span>, <span class="symbol">:action</span> =&gt; <span class="string">'notify'</span><span class="brackets">)</span>
    service<span class="method">.return_url</span> url_for<span class="brackets">(</span><span class="symbol"> <img src='http://blog.bhushangahire.net/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nly_path</span> =&gt; <span class="constants">false</span>,
        <span class="symbol">:controller</span> =&gt; <span class="string">'account'</span>, <span class="symbol">:action</span> =&gt; <span class="string">'show'</span><span class="brackets">)</span>
    service<span class="method">.cancel_return_url</span> url_for<span class="brackets">(</span><span class="symbol"> <img src='http://blog.bhushangahire.net/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nly_path</span> =&gt; <span class="constants">false</span>,
        <span class="symbol">:controller</span> =&gt; <span class="string">'account'</span>, <span class="symbol">:action</span> =&gt; <span class="string">'show'</span><span class="brackets">)</span> <span class="tag">%&gt;</span>

    &lt;!-- display payment summary here --&gt;

    <span class="tag">&lt;%=</span> submit_tag <span class="string">'Make Payment'</span> <span class="tag">%&gt;</span>
<span class="tag">&lt;%</span> <span class="keywords">end</span> <span class="tag">%&gt;</span></code></pre>
<p>The code above refers to the constant <code>PAYPAL_ACCOUNT</code>, which I define in <code>environment.rb</code>.  I also set Active Merchant to use test mode, which directs it to use Paypal’s sandbox:</p>
<pre><code class="ruby"><span class="keywords">unless</span> <span class="constants">RAILS_ENV</span> == <span class="string">'production'</span>
  <span class="constants">PAYPAL_ACCOUNT</span> = <span class="string">'sandboxaccount@example.com'</span>
  <span class="constants">ActiveMerchant</span>:<span class="symbol">:Billing</span>:<span class="symbol">:Base</span><span class="method">.mode</span> = <span class="symbol">:test</span>
<span class="keywords">else</span>
  <span class="constants">PAYPAL_ACCOUNT</span> = <span class="string">'paypalaccount@example.com'</span>
<span class="keywords">end</span></code></pre>
<h3>Create an action that processes the <span class="caps">IPN</span></h3>
<p>After the above form submits to Paypal and the user makes a payment, Paypal will post data about the transaction to your server.  Set up an action to receive the post:</p>
<pre><code class="ruby">  <span class="keywords">def</span> notify
    notify = <span class="constants">Paypal</span>:<span class="symbol">:Notification</span><span class="method">.new</span><span class="brackets">(</span>request<span class="method">.raw_post</span><span class="brackets">)</span>
    enrollment = <span class="constants">Enrollment</span><span class="method">.find</span><span class="brackets">(</span>notify<span class="method">.item_id</span><span class="brackets">)</span>

    <span class="keywords">if</span> notify<span class="method">.acknowledge</span>
      <span class="instance">@payment</span> = <span class="constants">Payment</span><span class="method">.find_by_confirmation</span><span class="brackets">(</span>notify<span class="method">.transaction_id</span><span class="brackets">)</span> ||
        enrollment<span class="method">.invoice</span><span class="method">.payments</span><span class="method">.create</span><span class="brackets">(</span><span class="symbol">:amount</span> =&gt; notify<span class="method">.amount</span>,
          <span class="symbol">:payment_method</span> =&gt; <span class="string">'paypal'</span>, <span class="symbol">:confirmation</span> =&gt; notify<span class="method">.transaction_id</span>,
          <span class="symbol">:description</span> =&gt; notify<span class="method">.params</span><span class="brackets">[</span><span class="string">'item_name'</span><span class="brackets">]</span>, <span class="symbol">:status</span> =&gt; notify<span class="method">.status</span>,
          <span class="symbol">:test</span> =&gt; notify<span class="method">.test?</span><span class="brackets">)</span>
      begin
        <span class="keywords">if</span> notify<span class="method">.complete?</span>
          <span class="instance">@payment</span><span class="method">.status</span> = notify<span class="method">.status</span>
        <span class="keywords">else</span>
          logger<span class="method">.error</span><span class="brackets">(</span><span class="string">"Failed to verify Paypal's notification, please investigate"</span><span class="brackets">)</span>
        <span class="keywords">end</span>
      <span class="keywords">rescue</span> =&gt; e
        <span class="instance">@payment</span><span class="method">.status</span> = <span class="string">'Error'</span>
        <span class="keywords">raise</span>
      ensure
        <span class="instance">@payment</span><span class="method">.save</span>
      <span class="keywords">end</span>
    <span class="keywords">end</span>
    render <span class="symbol">:nothing</span> =&gt; <span class="constants">true</span>
  <span class="keywords">end</span></code></pre>
<p>Depending on the model for your application, this action will obviously look different. The important part is that you pass the raw post data from the request to <code>Paypal::Notification.new</code>, and call <code>notify.acknowledge</code> to connect back to Paypal to verify the data.</p>
<h3>Enable <span class="caps">IPN</span></h3>
<p>Lastly, log into the business account that you created above, go to <em>“Instant Payment Notification Preferences”</em> in your profile, and set the <span class="caps">URL</span> that Paypal should post back to after payments. (Note: this needs to be a publicly accessible <span class="caps">URL</span>.)</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2009/08/05/paypal-instant-payment-notification-in-rails-with-active-merchant/&amp;title=Paypal+Instant+Payment+Notification+in+Rails+with+Active+Merchant" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2009/08/05/paypal-instant-payment-notification-in-rails-with-active-merchant/&amp;title=Paypal+Instant+Payment+Notification+in+Rails+with+Active+Merchant" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2009/08/05/paypal-instant-payment-notification-in-rails-with-active-merchant/&amp;title=Paypal+Instant+Payment+Notification+in+Rails+with+Active+Merchant" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2009/08/05/paypal-instant-payment-notification-in-rails-with-active-merchant/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2009/08/05/paypal-instant-payment-notification-in-rails-with-active-merchant/&amp;t=Paypal+Instant+Payment+Notification+in+Rails+with+Active+Merchant" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Paypal+Instant+Payment+Notification+in+Rails+with+Active+Merchant+-+http://tr.im/SU8n+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2009/08/05/paypal-instant-payment-notification-in-rails-with-active-merchant/&amp;title=Paypal+Instant+Payment+Notification+in+Rails+with+Active+Merchant&amp;summary=Active%20Merchant%20makes%20it%20extremely%20simple%20to%20use%20Paypal%20IPN.%20Here%20is%20a%20simple%20guide%20for%20getting%20IPN%20up%20and%20running.%0A%0ASign%20up%20for%20a%20Paypal%20sandbox%20account%0APaypal%20provides%20a%20sandbox%20environment%20that%20mimics%20their%20production%20environment%2C%20with%20the%20exception%20that%20it%20doesn%E2%80%99t%20actually%20process%20the%20transact&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2009%2F08%2F05%2Fpaypal-instant-payment-notification-in-rails-with-active-merchant%2F&amp;t=Paypal+Instant+Payment+Notification+in+Rails+with+Active+Merchant" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2009/08/05/paypal-instant-payment-notification-in-rails-with-active-merchant/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Install and Configure FTP Server in Amazon EC2 instance</title>
		<link>http://blog.bhushangahire.net/2009/04/15/install-and-configure-ftp-server-in-amazon-ec2-instance/</link>
		<comments>http://blog.bhushangahire.net/2009/04/15/install-and-configure-ftp-server-in-amazon-ec2-instance/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 14:17:51 +0000</pubDate>
		<dc:creator>Bhushan Ahire</dc:creator>
				<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[live]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[setup]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=97</guid>
		<description><![CDATA[
For many users, running FTP Sever in Amazon EC2 instance is headache at the first time. You need to experiment before being able to transfer data. The main problems are Ingress firewall in Amazon environment and NAT traversal.
Here I’m using vsftp (vsfptd) Server, which is one of the most popular and easy to configure. The [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2009%2F04%2F15%2Finstall-and-configure-ftp-server-in-amazon-ec2-instance%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<p>For many users, running FTP Sever in Amazon EC2 instance is headache at the first time. You need to experiment before being able to transfer data. The main problems are Ingress firewall in Amazon environment and NAT traversal.</p>
<p>Here I’m using vsftp (vsfptd) Server, which is one of the most popular and easy to configure. The instance is running from base Fedora 4 AMI but the setup should be identical to other Red Hat based distros.</p>
<p>Install vsftpd FTP server, if not installed earlier: </p>
<p><code># yum install vsfptd</code></p>
<p>Its upto you which FTP method i.e. Active or Passive you want to use. The problem with active mode is that your computer is sending a request out of port 21 when all of a sudden, the server attempts to initiate a request with your computer on port 20.  Since communication on port 21 does not imply communication on port 20, it appears as if some unauthorized host has attempted to initiate a new connection with your computer.  Kind of sounds like a hack right?  Your firewall may think so too (or your NAT router may have no idea to which computer to route the request). Active mode is not used as default method of ftp transfer in many clients these days. </p>
<p>On the other hand, as the Ingress firewall is running in AWS, from the firewall’s standpoint, to support passive mode FTP the following communication channels need to be opened:</p>
<p>FTP server’s port 21 from anywhere (Client initiates connection).<br />
FTP server’s port 21 to ports &gt; 1023 (Server responds to client’s control port).<br />
FTP server’s ports &gt; 1023 from anywhere (Client initiates data connection to random port specified by server).<br />
FTP server’s ports &gt; 1023 to remote ports &gt; 1023 (Server sends ACKs (and data) to client’s data port).</p>
<p>That second part is the problem: FTP server listens on a random port and hands that back to the client, so the client initiates a connection to a random server port, which you must allow.</p>
<p>Opening up all ports &gt; 1023 isn’t so good for security. But what you can do is allow the ports through the distributed firewall and then setup your own filtering inside your instance. Instead, you would better open a fixed number of ports (such as 1024 to 1048) and configure your FTP Server to only use that ports.</p>
<p>Check whether required ports are open or not in your EC2 security group. (if you are unaware about security group, it should be ‘defaul’ unless you created a new one). </p>
<p><code># ec2-describe-group</code></p>
<p>This command will print all ports which are currently open. If you dont find port 20,21,1024-1048 then you need to open these ports but if you dont find the command itself i.e.<br />
<code># ec2-describe-group<br />
-bash: ec2-describe-group: command not found</code></p>
<p>You need to install ec2 command line tools. You can find them <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&amp;categoryID=88" onclick="javascript:urchinTracker('/outbound/developer.amazonwebservices.com/connect/entry.jspa?externalID=351_038_categoryID=88?ref=http_//www.google.co.in/search?hl=en_client=firefox-a_rls=org.mozilla_3Aen-US_3Aofficial_q=how+to+connect+amazon+ec2+instance+with+sftp_btnG=Search_meta=_aq=o_oq=');">here</a>  and the instructions to setup/configure can be found <a href="http://docs.amazonwebservices.com/AWSEC2/2008-02-01/GettingStartedGuide/?ref=get-started" onclick="javascript:urchinTracker('/outbound/docs.amazonwebservices.com/AWSEC2/2008-02-01/GettingStartedGuide/?ref=get-started?ref=http_//www.google.co.in/search?hl=en_client=firefox-a_rls=org.mozilla_3Aen-US_3Aofficial_q=how+to+connect+amazon+ec2+instance+with+sftp_btnG=Search_meta=_aq=o_oq=');">here.</a> </p>
<p>Open the ports now: </p>
<p><code># ec2-authorize default -p 20-21<br />
# ec2-authorize default -p 1024-1048</code></p>
<p>Here, ‘default’ is the name of security group. You can also open ports for specific IPs. For ease of use, you better install ElasticFox, a firefox extension to manage EC2 stuff. you can find more about it <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=609" onclick="javascript:urchinTracker('/outbound/developer.amazonwebservices.com/connect/entry.jspa?externalID=609?ref=http_//www.google.co.in/search?hl=en_client=firefox-a_rls=org.mozilla_3Aen-US_3Aofficial_q=how+to+connect+amazon+ec2+instance+with+sftp_btnG=Search_meta=_aq=o_oq=');">here.</a> </p>
<p>At this moment, you can start your FTP server and if you try to connect it, the process will get failed. By checking logs, you should find something like:</p>
<p><code>Status: Connected<br />
Status: Retrieving directory listing...<br />
Command: PWD<br />
Response: 257 "/" is current directory.<br />
Command: TYPE A<br />
Response: 200 Type set to A<br />
Command: PASV<br />
Response: 227 Entering Passive Mode (216,182,238,73,129,75).<br />
Command: LIST<br />
Error: Transfer channel can't be opened. Reason: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.<br />
Error: Could not retrieve directory listing<br />
</code></p>
<p>Time to configure vsftpd.conf file:<br />
<code># vi /etc/vsftpd/vsftpd.conf<br />
---Add following lines at the end of file---<br />
	pasv_enable=YES<br />
	pasv_min_port=1024<br />
	pasv_max_port=1048<br />
	pasv_address=<strong>Public IP of your instance</strong></code></p>
<p>Put public IP of your EC2 instance and then Save the file. Now restart the server: </p>
<p><code># /etc/init.d/vsftpd restart</code></p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2009/04/15/install-and-configure-ftp-server-in-amazon-ec2-instance/&amp;title=Install+and+Configure+FTP+Server+in+Amazon+EC2+instance" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2009/04/15/install-and-configure-ftp-server-in-amazon-ec2-instance/&amp;title=Install+and+Configure+FTP+Server+in+Amazon+EC2+instance" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2009/04/15/install-and-configure-ftp-server-in-amazon-ec2-instance/&amp;title=Install+and+Configure+FTP+Server+in+Amazon+EC2+instance" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2009/04/15/install-and-configure-ftp-server-in-amazon-ec2-instance/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2009/04/15/install-and-configure-ftp-server-in-amazon-ec2-instance/&amp;t=Install+and+Configure+FTP+Server+in+Amazon+EC2+instance" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Install+and+Configure+FTP+Server+in+Amazon+EC2+instance+-+http://tr.im/SU8v+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2009/04/15/install-and-configure-ftp-server-in-amazon-ec2-instance/&amp;title=Install+and+Configure+FTP+Server+in+Amazon+EC2+instance&amp;summary=For%20many%20users%2C%20running%20FTP%20Sever%20in%20Amazon%20EC2%20instance%20is%20headache%20at%20the%20first%20time.%20You%20need%20to%20experiment%20before%20being%20able%20to%20transfer%20data.%20The%20main%20problems%20are%20Ingress%20firewall%20in%20Amazon%20environment%20and%20NAT%20traversal.%0AHere%20I%E2%80%99m%20using%20vsftp%20%28vsfptd%29%20Server%2C%20which%20is%20one%20of%20the%20most%20popular%20&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2009%2F04%2F15%2Finstall-and-configure-ftp-server-in-amazon-ec2-instance%2F&amp;t=Install+and+Configure+FTP+Server+in+Amazon+EC2+instance" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2009/04/15/install-and-configure-ftp-server-in-amazon-ec2-instance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
