apache mobilefilter 4-03

74
Apache Mobile Filter Suite (V4.03) by Idel Fuschini ([email protected] ) 09/08/2013 Apache Mobile Filter

Upload: idel-fuschini

Post on 07-Dec-2014

6.945 views

Category:

Technology


0 download

DESCRIPTION

Apache Mobile Filter is the easiest way to detect mobile devices. AMF is a suite of tools that allow access to a Device Repository (such as WURFL, DetectRight, 51Degrees or others) directly from Apache: now you can detect devices no matter what language your website uses.

TRANSCRIPT

Page 1: Apache mobilefilter 4-03

Apache Mobile Filter Suite(V4.03)

byIdel Fuschini ([email protected])09/08/2013

Apache Mobile Filter

Page 2: Apache mobilefilter 4-03

Intro to AMF

Page 3: Apache mobilefilter 4-03

Every year more then 300 new devices

Device Fragmentation ProblemApacheMobile Filter

Page 4: Apache mobilefilter 4-03

Each mobile device has many capabilities

screensize ?

imagetype ?

wifi ?

xhtml ?

screen resolution ?

navigation type ?

streaming type ?video streaming type ?

ajax ?

gif animated ?j2me ?os ?

gif animated ?

ApacheMobile Filter

Page 5: Apache mobilefilter 4-03

The Goal

• Help people to detect easily any type of device

• have one solution for any platform (Unix, linux, OS X, Windows)

• give a simple solution for any programming language (PHP, Python, JSP, Ruby, Perl etc....)

• Manage Images easily

• High performane

ApacheMobile Filter

Page 6: Apache mobilefilter 4-03

Who is using AMF

Under test....

Page 7: Apache mobilefilter 4-03

What is the Apache Mobile Filter Project ?

“Idel Fuschini has created Apache Mobile Filter that allows you to access WURFL from any programming language, not just Java and php that is traditionally used for dynamic mobile web sites.

The module detects the mobile device and passes the WURFL capabilities on to the other web application as environment variables. It can also be used to resize images on the fly to adapt to the screen size of the mobile device.”

from http://mobilephonedevelopment.com/archives/854

ApacheMobile Filter

Page 8: Apache mobilefilter 4-03

Why Apache ?for more 235,000,000 reasons

*from http://news.netcraft.com

Market Share for Top Servers Across All Domains August 1995 - July 2011

ApacheMobile Filter

Page 9: Apache mobilefilter 4-03

Some info where download the software and doc

Official Site: http://www.idelfuschini.it/apache-mobile-filter-v2x.html

Demo Site for mobile:http://www.apachemobile.org

Demo Site for PC:http://www.apachemobile.org

Support: [email protected] Mobile Filter ticket system: http://amfticket.idelfuschini.it

Download Site:

http://sourceforge.net/projects/mobilefilter/

or

http://search.cpan.org/~ifuschini/

ApacheMobile Filter

Page 10: Apache mobilefilter 4-03

The "Apache Mobile Filter" is one of the modules of "Apache Module Registry" portal.

http://modules.apache.org/search.php?id=1787

modules.apache.org

ApacheMobile Filter

Page 11: Apache mobilefilter 4-03

Success HistoryApacheMobile Filter

http://mobile.telecomitalia.it

Page 12: Apache mobilefilter 4-03

Success HistoryApacheMobile Filter

http://m.enter.co

Page 13: Apache mobilefilter 4-03

Success History

http://m.oc2ps.com

ApacheMobile Filter

Page 14: Apache mobilefilter 4-03

Success History

http://m.eltiempo.com

ApacheMobile Filter

Page 15: Apache mobilefilter 4-03

Success History

Repair Shop Websites: The Leader in Internet Designfor the Automotive Repair Industry

“......Knowing how many phones are available for people to search and surf the web, we wanted to find a solution that would automatically optimize our sites no matter what mobile device was being used. We found the ultimate solution in the Apache Mobile Filter. .......”

Page 16: Apache mobilefilter 4-03

Success History

http://m.portafolio.com.co

ApacheMobile Filter

Page 17: Apache mobilefilter 4-03

Success History

http://m.vive.in

ApacheMobile Filter

Page 18: Apache mobilefilter 4-03

Success History

http://mobile.finanze.it

ApacheMobile Filter

Page 19: Apache mobilefilter 4-03

People says......

Silvian Leuthold:“After many years in mobile industry I can say that AMF is simply the most straightforward approach I've seen for solving common mobile internet challenges like device recognition, media delivery and mobile web design. Thanks a lot to Idel who was always available for support and consulting when needed. Great Job!. October 21, 2011”

Scott Pakin:Given the mess the mobile Web is in, with devices ignoring handheld-targeting stylesheets, lying about their screen resolution, and otherwise impeding the development of portable Web sites, Apache Mobile Filter really helps tame the complexity of delivering content that's suitably formatted for the target device. November 02, 2011

ApacheMobile Filter

Page 20: Apache mobilefilter 4-03

People says......

Sergio David Acosta:“Gracias a Idel y a su grandioso producto, el Apache Mobile Filter, que nos permitió desarrollar los portales móviles de Casa Editorial El Tiempo. February 15, 2010”Kumaraswamy Nandipati:“I did a lot R&D for image rendering on the fly for one of my mobile website and finally it was ended up with Apache-mobile Filter. It was nice tool and easy to adopt. I simply Love it. I appreciate idle effort for this tool. Thanks for providing such a nice tool Idle Fu. -Kumaraswamy.N Project Lead, ecomZera LLC.” January 16, 2010Massimiliano Martinelli:Very useful project, "mobilize" a portal in a very easy and fast way! The AMF provides an all-in-one suite in order to manage contents for mobiles in the best way!Project Lead, Devoteam July, 2010

ApacheMobile Filter

Page 21: Apache mobilefilter 4-03

AMF Architecture

Apache Mobile FilterSuite

Device Repository

Apache Standard Environment Apache Mobile Environment (Device Capability)

WebApplication(php,python, ruby, jsp, perl, asp etc. etc.)

Apache Webserver

mod_perl 2.0.X

Apache Web Server (http://apache.org)mod_perl2 (http://perl.apache.org)WURFL (http://wurfl.sourceforge.net)

ApacheMobile Filter

Page 22: Apache mobilefilter 4-03

Installation requirement

• perl v5.8.8 or more (http://www.perl.org)

• apache webserver 2.x or more (http://httpd.apache.org)

• mod_perl 2.0.4 or more (http://perl.apache.org)

• memcached 1.4.4 or more (http://memcached.org)

mkdir foocd foowget http://downloads.sourceforge.net/project/mobilefilter/ApacheMobileFilter/x.xx/Apache2-WURFLFilter-x.xx.tar.gz?use_mirror=dfntar -xzvf Apache2-WURFLFilter-x.xx.tar.gzcd Apache2-WURFLFilter-x.xx/perl Makefile.PLmake installaptitude install libapache2-mod-perl2 libgd-gd2-perl libgd-toolsa2enmod perlcpan Apache2::AMFWURFLFilter Apache2::Filter Apache2::RequestRec Apache2::RequestUtil Apache2::Connection Apache2::SubRequest Apache2::Log CGI::Cookie APR::Table CGI::Cookie LWP::Simple Image::Resize Image::Scale IO::Uncompress::Unzip Cache::FileBackend Cache::Memcached

Download Apache Mobile Filter and follow this steps:

ApacheMobile Filter

Page 23: Apache mobilefilter 4-03

The AMF Suite

Page 24: Apache mobilefilter 4-03

Admin Tool

Apache Mobile Filter SuiteDevice Detection

Mobile Switcher

Image Rendering Engine

Carrier Detection

Mobile Caching System

ApacheMobile Filter

Mobile Trace

WebService

Page 25: Apache mobilefilter 4-03

AMF<DeviceRepsitory>Filter(Device Detection Module)

AMFImageRendering

Apache Web Server

AMF environment

PHPWebApp

JSPWebApp(mod_jk)

RUBY/PythonWebApp

MobileSite

Version

ClassicSite

Version

TranscoderSite

Version

Http

Red

irect

(301

)

Http

Red

irect

(301

)

Http

Red

irect

(301

)

htdocs

Mobile Web Server Architecure

AMFSwitcherAMFCarrierDetection

AMFMobileCaching

ApacheMobile Filter

AMFWebService

Third-partyapplications

Page 26: Apache mobilefilter 4-03

Advanced Cache System

• Two architecture of caching:

• The Apache Mobile Filter when it has identified a mobile device, stores the capabilities in a persistent cache (filesystem)

• The Apache Mobile Filter when it has identified a mobile device, stores the capabilities using memcached (http://memcached.org). Ideal solutions in cluster architectures.

ApacheMobile Filter

Page 27: Apache mobilefilter 4-03

Device Detection

ApacheMobile Filter

Page 28: Apache mobilefilter 4-03

Device Detection overviewAMF suite from 3.40a version supports several device repositories, each Device Repository has a dedicated module

• AMFLiteDetectionFilter: is suggested to use for solution that not need exaclty the type of device, but only if the device is amobile or not. Is nor require a Device Repository

• AMF51DegreesFilter*: this module use 51Degrees (http://51degrees.mobi) as device Repository

• AMFDetectRightFilter*: this module use DetectRight (http://www.detectright.com) as device Repository

• AMFWURFLFilter*: this module use DetectRight (http://www.scentiamobile.com) as device Repository

*this module has advanced cache system on filesystem or using memcached

ApacheMobile Filter

Page 29: Apache mobilefilter 4-03

Device Detection Manager

EnvironmentManager

LiteIdentification(memory storage)

AMF Device Detection Module

AMFDetectLiteFilter(caching filesystem based)

ApacheMobile FilterDevice Detection

On LineUpdate

Page 30: Apache mobilefilter 4-03

ConfigurationWurflFilter

Open the file httpd.conf of your webserver. And configure this few parameter:

PerlSetEnv AMFMobileHome server_root/MobileFilter

PerlTransHandler +Apache2::AMFLiteDetectionFilter

Remember:This module is suggested to use only to use with AMFSwitch module, is not so precise how to use a Device Repository

At startuo the module verify on apachemobilefilter.org if there are new parameter to get, ig you want to disable this option you can set:

PerlSetEnv AMFDownloadParamURL on true

In production is suggested to set the AMFProductionMode on true:

PerlSetEnv AMFProductionMode on true

ApacheMobile FilterDevice Detection

Page 31: Apache mobilefilter 4-03

Device Detection Manager

CacheManager

DeviceRepository

(memory storage)

AMF Device Detection Module

EnvironmentManager

AMF<DeviceRepository>Filter(caching filesystem based)

FileSystemCache

ApacheMobile FilterDevice Detection

Page 32: Apache mobilefilter 4-03

ConfigurationOpen the file httpd.conf of your webserver. And configure this few parameter:

PerlSetEnv AMFMobileHome server_root/MobileFilterPerlSetEnv CacheDirectoryStore /tmp

PerlSetEnv CapabilityList xhtml_table_support, is_wireless_device, etc...... #default is all

PerlTransHandler +Apache2::AMF<DeviceRepository>Filter

Remember:before you start you must have the device repository fileif you want to update the device repositoryl file each time you stop and start the Apache, you must specify with this parameter:PerlSetEnv <device repository>NetDownload truePerlSetEnv Download<device repoisory>URL http://<url>/<device repository>.zip

In production is suggested to set the AMFProductionMode on true:

PerlSetEnv AMFProductionMode on true

ApacheMobile FilterDevice Detection

Page 33: Apache mobilefilter 4-03

ConfigurationWurflFilter

If you need to add more capabilities or useragents that are not includes into the DeviceRepository add this papameter:

PerlSetEnv PersonalWurflFileName mydevicerepository.xml

The path is the AMF_Home. An example for your device repository file:

<wurfl_patch> <devices> <device user_agent="mickey mouse" fall_back="root" id="generic"> <group id="fb"> <capability name="mynewcapability" value="false"/> </group> </device> <device id="apple_iphone_ver4_3"> <group id="fb"> <capability name="mynewcapability" value="true"/> </group> </device> </devices></wurfl_patch>

ApacheMobile FilterDevice Detection

Page 34: Apache mobilefilter 4-03

AMF with Memcachedthe advantage to use AMFWURFLFilterMemcached

This picture and the text are from http://memcached.org and can explain the advantage of this architecture:

“memcached allows you to take memory from parts of your system where you have more than you need and make it accessible to areas where you have less than you need.

memcached also allows you to make better use of your memory. If you consider the diagram to the right, you can see two deployment scenarios:

! 1.! Each node is completely independent (top).! 2.! Each node can make use of memory from other nodes (bottom).The first scenario illustrates the classic deployment strategy, however you'll find that it's both wasteful in the sense that the total cache size is a fraction of the actual capacity of your web farm, but also in the amount of effort required to keep the cache consistent across all of those nodes.

With memcached, you can see that all of the servers are looking into the same virtual pool of memory. This means that a given item is always stored and always retrieved from the same location in your entire web cluster.

Also, as the demand for your application grows to the point where you need to have more servers, it generally also grows in terms of the data that must be regularly accessed. A deployment strategy where these two aspects of your system scale together just makes sense.

The illustration to the right only shows two web servers for simplicity, but the property remains the same as the number increases. If you had fifty web servers, you'd still have a usable cache size of 64MB in the first example, but in the second, you'd have 3.2GB of usable cache.

Of course, you aren't required to use your web server's memory for cache. Many memcached users have dedicated machines that are built to only be memcached servers.”*

*from http://memcached.org/about

ApacheMobile FilterDevice Detection

Page 35: Apache mobilefilter 4-03

Apache WebServer

Apache Mobile FilterMemcached cluster architecture

Memcached*

*http://memcached.org/

Apache Mobile Filter

Apache WebServerApache Mobile Filter

Apache WebServerApache Mobile Filter

ApacheMobile FilterDevice Detection

Page 36: Apache mobilefilter 4-03

AMFWURFLFilterMemcached

Device Detection Manager

AMFWURFFilterMemcahed

EnvironmentManager Memcached*Cache

Manager

Device DetectionApacheMobile Filter

DeviceRepository

(memory storage)

Page 37: Apache mobilefilter 4-03

Configuration Open the file httpd.conf of your webserver. And configure this few parameter:

PerlSetEnv AMFMobileHome server_root/MobileFilterPerlSetEnv ServerMemCached 10.0.0.15:11211,10.0.0.16:11211,/var/sock/memcahed

PerlSetEnv CapabilityList xhtml_table_support, is_wireless_device, etc...... #default is all

PerlTransHandler +Apache2::AMF<DeviceRepository>FilterMemcached

Remember:before you start you must have the device repository fileif you want to update the device repository file each time you stop and start the Apache, you must specify with this parameter:PerlSetEnv <device repository>NetDownload truePerlSetEnv Download<device repoisory>URL http://<url>/<device repository>.zip

If you want to detect the not mobile browser you must need to load the web_browser_patch.xml so set this parameter to true:PerlSetEnv LoadWebPatch trueIf you want to download directly from internet (it’s very slow):PerlSetEnv PatchWurflNetDownload truePerlSetEnv PatchWurflUrl http://wurfl.sourceforge.net/web_browsers_patch.xml

In production is suggested to set the AMFProductionMode on true: PerlSetEnv AMFProductionMode true

Device DetectionApacheMobile Filter

Page 38: Apache mobilefilter 4-03

Mobile Caching System

ApacheMobile Filter

Page 39: Apache mobilefilter 4-03

Mobile Caching System (beta version)(for cluster architecture using memcached)

AMFMobileCachingMemcached

memcachedserver

AMFMobileCachingMemcached cache the different layout, of the same URL, for each type of devices that have done the requests.The timeout caching is configurable.

Mobile Cache SystemApacheMobile Filter

Page 40: Apache mobilefilter 4-03

Configuration Open the file httpd.conf of your webserver. And configure this few parameter:

PerlSetEnv AMFMobileHome /server_root/MobileFilterPerlSetEnv ServerMemCached 10.0.0.15:11211,10.0.0.16:11211,/var/sock/memcahed

CapabilityList xhtml_table_support, is_wireless_device, etc...... #default is all

PerlTransHandler +Apache2::AMFWURFLFilterMemcached

<Directory /portal/*> SetHandler modperl PerlOutputFilterHandler Apache2::AMFMobileCacheMemcached Allow from all</Directory>

ApacheMobile FilterMobile Cache System

Page 41: Apache mobilefilter 4-03

Image Rendering Engine

ApacheMobile Filter

Page 42: Apache mobilefilter 4-03

Image Render

AMFImageRendering

Original ImagesDirectory

Cached ImagesDirectory

Image Rendering Filter

Image Rendering EngineApacheMobile Filter

Page 43: Apache mobilefilter 4-03

ConfigurationThe AMFImageRendering is working only if is active the WURFLFilter.

Open the file httpd.conf of your webserver. And configure this few parameter:

PerlSetEnv AMFMobileHome /server_root/MobileFilter

PerlSetEnv ResizeImageDirectory /tmp/cached

PerlModule Apache2::AMFWURFLFilterPerlTransHandler +Apache2::AMFWURFLFilter

<Location /mobile/*> SetHandler modperl PerlOutputFilterHandler Apache2::AMFImageRendering </Location>

This is indicate to the filter were are stored the high definition images

This indicate to the filter where put the transformated images (cache directory) this directory must be writeable

/mobile /transform(cache directory)

Browser Image Request

ImageRenderFilter Response

or AMFWURFLFilterMemcached

ApacheMobile FilterImage Render Engine

Page 44: Apache mobilefilter 4-03

Image Render FilterHTML Syntax

<img src=”/mobile/image.png”>

<img src=”/mobile/image.png?dim=50”>

<img src=”/mobile/image.png?width=80”>The width of the image is 80px

The image is scaled to the 50% of the width mobile device

The image is scaled to the size of the mobile device

ApacheMobile FilterImage Render Engine

For change the name of parameter “width” and “dim” in httpd.conf must be setted:PerlSetEnv ImageParamWidth <new name of param>PerlSetEnv ImageParamPerc <new name of param>

By default the images that have a width less than device screen size are not resized, if you want to force it:

PerlSetEnv ResizeSmallImage true

Page 45: Apache mobilefilter 4-03

image1 image2

image3

logo

image5image4

(max_image_width)

<img src=”/mobile/logo.png”>

<img src=”/mobile/image1.png?&dim=50”><img src=”/mobile/image2.png?&dim=50”>

<img src=”/mobile/image5.png?dim=50”>

<img src=”/mobile/image4.png?&dim=33”>

<img src=”/mobile/image3.png?&dim=33”>

Image Render FilterApacheMobile Filter

Image Render Engine

Page 46: Apache mobilefilter 4-03

Mobile Switcher

ApacheMobile Filter

Page 47: Apache mobilefilter 4-03

AMFSwitcher

AMFSwitcherSwitcher Manager

Mobile SwitcherApacheMobile Filter

Page 48: Apache mobilefilter 4-03

You can use the filter to redirect to other part if it came from:

web browsermobile browsertranscoder

Open the file httpd.conf of your webserver. And configure this few parameters*:

PerlSetEnv FullBrowserUrl http://www.fullbrowsersite.com

PerlSetEnv MobileVersionUrl http://www.mobilesite.com

PerlSetEnv RedirectTranscoderUrl http://www.transcodersite.com**

PerlSetEnv AMFMobileHome server_root/MobileFilter

PerlModule Apache2::AMFWURFLFilterPerlTransHandler +Apache2::AMFWURFLFilterPerlTransHandler +Apache2::AMFSwitcher

ConfigurationConfigure AMFSwitcher

1) http://m.site.com

2) http://www.site.com

3) http://www.transcoder.com

*FullBrowserUrl, MobileVersionUrl, RedirectTranscoder are optional, but minumum one of them must be set**if the parameter “RedirectTranscoder” is omitted the transcoders are considered as mobile devices.

ApacheMobile Filter Mobile Switcher

Page 49: Apache mobilefilter 4-03

You can use the filter to redirect to other part if it came from:

web browsermobile browsertranscoder

Open the file httpd.conf of your webserver. And configure this few parameters*:

PerlSetEnv FullBrowserUrl /web_dedicated_site

PerlSetEnv MobileVersion /mobile_dedicated_site

PerlSetEnv RedirectTranscoderUrl /transcoder_dedicates_site

PerlSetEnv AMFMobileHome server_root/MobileFilter

PerlTransHandler +Apache2::AMFWURFLFilterPerlTransHandler +Apache2::AMFSwitcher

ConfigurationAMFSwitcher (redirect in the same site)

*FullBrowserUrl, MobileVersionUrl, RedirectTranscoder are optional, but minumum one of them must be set

If for example you change the FullBrowserUrl parameter with value “/”, you defined that FullBrowser devices can access to all site.

ApacheMobile Filter Mobile Switcher

Page 50: Apache mobilefilter 4-03

Open the file httpd.conf of your webserver. And configure this few parameters*:

PerlSetEnv AMFMobileHome server_root/MobileFilterPerlSetEnv FullBrowserUrl /web

PerlSetEnv MobileVersion /mobilePerlSetEnv RedirectTranscoderUrl /transcoder_dedicates_site

PerlSetEnv WildCardRedirect true

PerlTransHandler +Apache2::AMFWURFLFilterPerlTransHandler +Apache2::AMFSwitcher

ConfigurationAMFSwitcher (redirect in the same site)

*FullBrowserUrl, MobileVersionUrl, RedirectTranscoder are optional, but minumum one of them must be set

ApacheMobile Filter Mobile Switcher

http://www.site.org/mobile/hello.html?go=12 http://www.site.org/web/hello.html?go=12Redirect for pc browser

Redirect for mobile browser

Page 51: Apache mobilefilter 4-03

Open the file httpd.conf of your webserver. And configure this few parameters*:

PerlSetEnv AMFMobileHome server_root/MobileFilterPerlSetEnv FullBrowserUrl /web_dedicated_site

PerlSetEnv MobileVersion /mobile_dedicated_site

PerlSetEnv RedirectTranscoderUrl /transcoder_dedicates_site

PerlSetEnv WildCardRedirect true #or false

PerlSetEnv AMFSwitcherExclude /images/,php_test.php

PerlTransHandler +Apache2::AMFWURFLFilterPerlTransHandler +Apache2::AMFSwitcher

ConfigurationAMFSwitcher (redirect in the same site)

*FullBrowserUrl, MobileVersionUrl, RedirectTranscoder are optional, but minumum one of them must be set

ApacheMobile Filter Mobile Switcher

Exclude the switcher from some path or file for example:

/images/ or php_test.php the images is not catched by AMFSwitcher

Page 52: Apache mobilefilter 4-03

Open the file httpd.conf of your webserver. And configure this few parameters*:

PerlSetEnv AMFMobileHome server_root/MobileFilterPerlSetEnv FullBrowserUrl /web

PerlSetEnv MobileVersion /mobilePerlSetEnv RedirectTranscoderUrl /transcoder_dedicates_site

PerlSetEnv FullBrowserMobileAccessKey fullbrowser #the value you can change

PerlTransHandler +Apache2::AMFWURFLFilterPerlTransHandler +Apache2::AMFSwitcher

ConfigurationAMFSwitcher (redirect in the same site)

*FullBrowserUrl, MobileVersionUrl, RedirectTranscoder are optional, but minumum one of them must be set

ApacheMobile Filter Mobile Switcher

This configuration permits to a mobile device to access on Desktop version of the site. For example in mobile site version you can put this link:

<a href=”/?fullbrowser”>Desktop Version</a>

Page 53: Apache mobilefilter 4-03

Open the file httpd.conf of your webserver. And configure this few parameters*:

PerlSetEnv AMFMobileHome server_root/MobileFilterPerlSetEnv FullBrowserUrl /web

PerlSetEnv MobileVersion /mobilePerlSetEnv RedirectTranscoderUrl /transcoder_dedicates_site PerlSetEnv ForceTabletAsFullBrowser true

PerlTransHandler +Apache2::AMFWURFLFilterPerlTransHandler +Apache2::AMFSwitcher

ConfigurationAMFSwitcher (redirect in the same site)

*FullBrowserUrl, MobileVersionUrl, RedirectTranscoder are optional, but minumum one of them must be set

ApacheMobile Filter Mobile Switcher

This configuration permits to a tablet device to access on Desktop version of the site.

Page 54: Apache mobilefilter 4-03

Carrier Detection

ApacheMobile Filter

Page 55: Apache mobilefilter 4-03

Carrier Detection

Carrier Detection Manager

Carrier IP Repository

(memory storage)

AMFCarrierDetection

EnvironmentManager

Carrier DetectionApacheMobile Filter

Page 56: Apache mobilefilter 4-03

ConfigurationCarrier Detection

PerlSetEnv AMFMobileHome server_root/MobileFilter PerlSetEnv CarrierNetDownload true #optional#

PerlSetEnv CarrierUrl http://www.andymoore.info/carrier-data.txtPerlTransHandler +Apache2::AMFCarrierDetection

Open the file httpd.conf of your webserver. And configure this few parameter:

The scope of this module is to identify the Carrier and its nation, and put it as environment variables called:

AMF_CARRIER_NAMEAMF_CARRIER_NATION

ApacheMobile Filter Carrier Detection

Page 57: Apache mobilefilter 4-03

Mobile Trace

ApacheMobile Filter

Page 58: Apache mobilefilter 4-03

The AMFTrace is working only if is active the WURFLFilter.

Open the file httpd.conf of your webserver. And configure this few parameter:

PerlSetEnv AMFMobileHome /server_root/MobileFilter

PerlSetEnv AMFTraceDebug false

PerlModule Apache2::AMFWURFLFilterPerlTransHandler +Apache2::AMFWURFLFilter

PerlTransHandler +Apache2::AMFTrace

Mobile Trace

The goal of this this configuration is to trace (on error_log file) the UserAgent no detected by AMF

Mobile Trace

or AMFWURFLFilterMemcached

ApacheMobile Filter

Page 59: Apache mobilefilter 4-03

Mobile Trace

The goal of this this configuration is to trace the wurfl capabities on error_log file, is useful for statistic scope or debug your applications.

Mobile Trace

The AMFTrace is working only if is active the WURFLFilter.

Open the file httpd.conf of your webserver. And configure this few parameter:

PerlSetEnv AMFMobileHome /server_root/MobileFilter

PerlSetEnv AMFTraceDebug truePerlSetEnv AMFTraceCapability id,brand_name

PerlModule Apache2::AMFWURFLFilterPerlTransHandler +Apache2::AMFWURFLFilter

PerlTransHandler +Apache2::AMFTrace

or AMFWURFLFilterMemcached

[Mon Mar 22 10:45:42 2010] [warn] [client ::1] AMFTrace - id=mozilla_ver5|brand_name=generic web browser| User_Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; it-it) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7

Example of error_log output:

ApacheMobile Filter

Page 60: Apache mobilefilter 4-03

Web Service

ApacheMobile Filter

Page 61: Apache mobilefilter 4-03

WebService

The goal of this this configuration is to give another way to give capabilities as xml or json.

WebService

The AMFWebService is working only if is active the WURFLFilter.

Open the file httpd.conf of your webserver. And configure this few parameter:

PerlSetEnv AMFMobileHome /server_root/MobileFilter

PerlSetEnv RestMode true

PerlModule Apache2::AMFWURFLFilterPerlTransHandler +Apache2::AMFWURFLFilter

<Location /WS/*> SetHandler modperl PerlResponseHandler Apache2::AMFWebService Allow from all</Location>

or AMFWURFLFilterMemcached

ApacheMobile Filter

only from V3.30 before wasPerlOutputFilterHandler

Page 62: Apache mobilefilter 4-03

WebServiceWebService

To have the wurfl capabilities as xml of some device you need to do this get:

GET http://<host>:<port>/WS/?<type=xml>&amf=<user_agent>

To have the wurfl capabilities as json of some device you need to do this get:

GET http://<host>:<port>/WS/?type=json&amf=<user_agent>

To have some capability you can add the capabilityListExample:

GET http://<host>:<port>/WS/?type=json&amf=<user_agent>&capabilityList=<capabiliy 1,capability 2, etc>

ApacheMobile Filter

If you use proxy to access to the AMFwebservice, is suggested to use AMFWSCacheControl. With this paramerer all proxy cache in middle don’t send many request to webservice. The syntax is:

PerlSetEnv AMFWSCacheControl max-age=2592000

Page 63: Apache mobilefilter 4-03

Admin Tool

ApacheMobile Filter

Page 64: Apache mobilefilter 4-03

Device MonitorDevices Detected

Devices not Detected

Devices Capabilities

Home Page

PerlSetEnv CacheDirectoryStore /tmp<Location /admin/*> PerlOutputFilterHandler Apache2::AMFDeviceMonitor</Location>

Configuration:

Carrier DetectionApacheMobile Filter

Page 65: Apache mobilefilter 4-03

How can I retrieve the values of the capabilities of wurfl?

Retrieve the WURFL capabilities value is very simple all the information are setting into the Apache Environment AMF_<uppercase wurfl capabilities name> for example:

To read the WURFL capabilities max_image_height you must read the environment value AMF_MAX_IMAGE_HEIGHT.

How to read environment in PHP ?

The php code is:

$_SERVER['AMF_MAX_IMAGE_HEIGHT'];

a test page in php is downloadable:

http://mobilefilter.cvs.sourceforge.net/viewvc/mobilefilter/ApacheMobileFilter/test_page/php/php_test.php?view=markup

How to read the value in JSP (for Tomcat)?

Before in the httpd.conf file where you have configure mod_jk you muse add this:

JkEnvVar AMF_MAX_IMAGE_HEIGHT undefined

The Java code is:

request.getAttribute("AMF_MAX_IMAGE_HEIGHT")

How to read the value in PERL?

print $ENV('AMF_MAX_IMAGE_HEIGHT');

ApacheMobile Filter

Page 66: Apache mobilefilter 4-03

AMF and mod_rewriteNow AMF is usable with mod_rewrite (http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html). The mod_rewrite can read the environment variables that AMF passes.The most important are:

AMF_DEVICE_IS_MOBILE, AMF_IS_TABLET

Here some example how to use it:

All mobile devices are redirect

In this example you can redirect only the mobile devices to the mobile site:

#Configuration AMF Filter#PerlSetEnv AMFMobileHome /usr/local/AMFPerlSetEnv AMFProductionMode truePerlSetEnv ServerMemCached localhost:11211

PerlTransHandler +Apache2::AMF<your favorite module>Filter# or PerlTransHandler +Apache2::AMF<your favorite module>FilterMemcachedRewriteEngine onRewriteCond %{ENV:AMF_DEVICE_IS_MOBILE} ^trueRewriteRule ^(.*)$ http://m.foo.org [R=301,L]

AMF<your favorite module>FilterMemcached is for AMFDetectRightFilter, AMF51DegreesFilter, AMFWURFLFilter and AMFLiteDetectionFilter

ApacheMobile Filter

Page 67: Apache mobilefilter 4-03

AMF and mod_rewriteAll mobile devices are redirect except tablet

In this other example you permit to tablet to access the desktop version:

#Configuration AMF Filter#PerlSetEnv AMFMobileHome /usr/local/AMFPerlSetEnv AMFProductionMode truePerlSetEnv ServerMemCached localhost:11211

PerlTransHandler +Apache2::AMF<your favorite module>Filter# or PerlTransHandler +Apache2::AMF<your favorite module>FilterMemcached

RewriteEngine onRewriteCond %{ENV:AMF_DEVICE_IS_MOBILE} ^trueRewriteCond %{ENV:AMF_DEVICE_IS_TABLET} !^trueRewriteRule ^(.*)$ http://m.foo.org [R=301,L]

AMF<your favorite module>FilterMemcached is for AMFDetectRightFilter, AMF51DegreesFilter, AMFWURFLFilter and AMFLiteDetectionFilter

ApacheMobile Filter

Page 68: Apache mobilefilter 4-03

AMF and mod_rewrite Permit mobile devices to access to desktop

Sometime it’s possible to be able to mobile device to access on PC site, with AMF is simple you need to define the FullBrowserMobileAccessKey like:

PerlSetEnv FullBrowserMobileAccessKey fullbrowser #the value you can change

and in your mobile page write this link:

<a href=”/?fullbrowser=true”>Desktop Version</a>

In httpd.conf the conditions are:

#Configuration AMF Filter#PerlSetEnv AMFMobileHome /usr/local/AMFPerlSetEnv AMFProductionMode truePerlSetEnv ServerMemCached localhost:11211PerlTransHandler +Apache2::AMF<your favorite module>Filter# or PerlTransHandler +Apache2::AMF<your favorite module>FilterMemcached

RewriteEngine onRewriteCond %{ENV:AMF_DEVICE_IS_MOBILE} ^trueRewriteCond %{ENV:AMF_DEVICE_IS_TABLET} !^trueRewriteCond %{ENV:AMF_FORCE_TO_DESKTOP} !^trueRewriteRule ^(.*)$ http://m.foo.org [R=301,L]

AMF<your favorite module>FilterMemcached is for AMFDetectRightFilter, AMF51DegreesFilter, AMFWURFLFilter and AMFLiteDetectionFilter

ApacheMobile Filter

Page 69: Apache mobilefilter 4-03

Example code in PHP<?php if ($_SERVER[AMF_XHTML_SUPPORT_LEVEL] != "-1") { ?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Apache Mobile Test</title><style type="text/css">

body { background-color: #FFFFFF; font-family: arial, helvetica, sans-serif; font-size: small; font-color: #000000 }</style><meta name = "viewport" content = "width = device-width"> </head> <body>Welcome to the Apache Mobile Test Page<br/><img src="/mobile/header.png" /><br/>Device data:<br/>ID: <b><?php echo $_SERVER['AMF_ID'] ?></b><br/><?php echo $tag ?>Brand name: <b><?php echo $_SERVER['AMF_BRAND_NAME'] ?></b><br/><?php echo $tag ?>Model name: <b><?php echo $_SERVER['AMF_MODEL_NAME'] ?></b><br/><?php echo $tag ?>Max Resolution:<b><?php echo $_SERVER['AMF_RESOLUTION_WIDTH'] ?> x <?php echo $_SERVER['AMF_RESOLUTION_HEIGHT'] ?></b><br/><?php echo $tag ?>Supp. J2ME MIDP 2.0:<b><?php echo $_SERVER['AMF_J2ME_MIDP_2_0'] ?></b><br/><?php echo $tag ?></body></html><?php} else {header("Content-type: text/vnd.wap.wml");print "<?xml version=\"1.0\"?>\n"; ?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml> <card id="card1" title="Apache Mobile Test"> <p>Device data:</p><p>Brand name: <?php echo $_SERVER['AMF_BRAND_NAME'] ?></p><p>Model name: <?php echo $_SERVER['AMF_MODEL_NAME'] ?></p><p>Max Resolution Height is <?php echo $_SERVER['AMF_RESOLUTION_HEIGHT'] ?></p><p>Max Resolution Width is <?php echo $_SERVER['AMF_RESOLUTION_WIDTH'] ?></p> </card></wml><?php} ?>

XHTML Version

WML Version

check if the device supporto XHTML

image rendering

ApacheMobile Filter

Page 70: Apache mobilefilter 4-03

AMF Test tool

Page 71: Apache mobilefilter 4-03

Who talks about “Apache Mobile Filter”

• “Gestire i dispositivi mobili con Apache Mobile Filter” (http://www.html.it/articoli/gestire-i-dispositivi-mobili-con-apache-mobile-filter/)

• “The Case of Open Source Development, a Personal Case Study” (http://robertogaloppini.net/2009/01/20/the-case-for-open-source-development-a-personal-case-study/)

• “Apache Mobile Filter” (http://mobilephonedevelopment.com/archives/854)

• “Un progetto italiano per l’identificazione dei dispositivi mobili” (http://www.blographik.it/2009/06/24/un-progetto-italiano-per-lidentificazione-dei-dispositivi-mobili/)

• “Apache Mobile Filter” (http://www.open4dev.com/journal/2009/6/29/apache-mobile-filter.html)

ApacheMobile Filter

Page 72: Apache mobilefilter 4-03

Who wrote about “Apache Mobile Filter”ApacheMobile Filter

Page 73: Apache mobilefilter 4-03

References• http://wurfl.sourceforge.net

• http://perl.apache.org

• http://modules.apache.org

• http://cpan.org

• http://memcached.org

• http://www.w3.org/TR/ct-guidelines/

• http://www.andymoore.info/wap-ip-to-carrier-detection/

ApacheMobile Filter

Page 74: Apache mobilefilter 4-03

THE ENDApache Mobile Filter