server {
	listen   80; 
 	server_name example1.com *.example1.com;
	location / {
		root /var/www/default;
		index index.html index.htm;
		if ($http_user_agent ~* '(iPhone|iPod)') { 
			set $iphone_request '1'; 
		} 
		if ($iphone_request = '1') { 
			rewrite ^.+ http://m.example1.com/$uri; 
		}
	}
}
