Monday, September 14, 2009

Apache2.2 Proxy and Virtual Hosts

I created a Flex application using TWITTER Webservices, Since the CrossDomain policy of Twitter is very strong, My flex app was working on the development mode in flex builder but not outside.

Solution implement a Proxy.. Twitter API is a pure REST API , which uses GET as well as POST requests..
Following solution of Apache Proxy, works with the get request

ServerName mysite.com
ServerAlias tp.mysite.com
DocumentRoot "/var/www/"
AddHandler php5-script .php
AddType text/html .php

ProxyRequests off
Order Allow,Deny
Allow from all
ProxyPass /tproxy/ http://twitter.com/
ProxyPassReverse /tproxy/ http://twitter.com/
RequestHeader unset Accept-Encoding

#custom log file
LogLevel debug
ErrorLog /var/log/httpd/caw.local.error.log
CustomLog /var/log/httpd/caw.local.access.log combined