We'll create fresh WordPress site with Nginx Mobile Theme installed. You have 20 minutes to test the plugin after that site we'll be deleted.
This plugin allows you to switch theme according to the User Agent on the Nginx reverse proxy.
Nginx Mobile Theme’s requirements are as follows.
Add mobile device detection to the nginx.conf.
set $mobile '';
if ($http_user_agent ~* '(iPhone|iPod|incognito|webmate|Android|dream|CUPCAKE|froyo|BlackBerry|webOS|s8000|bada|IEMobile|Googlebot\-Mobile|AdsBot\-Google)') {
set $mobile "@smartphone";
}
Set proxy_cache_key.
proxy_cache_key "$mobile$scheme://$host$request_uri";
Send custom request header to the backend.
proxy_set_header X-UA-Detect $mobile;
Nginx Mobile Theme will switch theme when ‘@smartphone’ is received in the $_SERVER['HTTP_X_UA_DETECT']
.
nginxmobile_mobile_detects
filter-hook.nginx.conf:
set $mobile ”;
if ($http_user_agent ~* ‘(iPhone|iPod)’) {
set $mobile “@smartphone”;
}
if ($http_user_agent ~* ‘iPad’) {
set $mobile “@tablet”;
}
In your custom plugin:
add_filter(‘nginxmobile_mobile_detects’, function(){
return array(‘@smartphone’, ‘@tablet’);
});
The Amimoto is a full-tuned WordPress AMI on the AWS EC2.
before:
#include /etc/nginx/mobile-detect;
after:
include /etc/nginx/mobile-detect;
before:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding “”;
after:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding “”;
proxy_set_header X-UA-Detect $mobile; # add new line
Define constant in the wp-config.php
define(‘IS_AMIMOTO’, true);