根据手机类型适配适当页面

本文介绍了在Debian系统下,如何利用Nginx根据用户手机的协议和分辨率来转发请求到相应站点。通过配置Nginx、使用第三方模块以及uWSGI,实现了针对手机和平板的页面适配。文章详细讲解了编译Nginx、安装uwsgi和ua-mapper库的过程,并提供了配置示例。
摘要由CSDN通过智能技术生成

debian根据手机类型适配适当页面

 

本文是参考如下2篇文章,debian下在nginx server level根据用户手机支持的协议(xhtmlwmlhtml)、屏幕分辨率等信息来将用户请求转发到相应站点的实现。手机支持的协议、分辨率、型号等是根据Useragent查询wurfl得到的。本文只是基于实现的目的,如果要实际应用可能还需要很多改进。

 

参考:http://www.28lines.com/?p=11

Uwsgi配置参考:https://library.linode.com/web-servers/nginx/python-uwsgi/debian-5-lenny

 

一、Nginx处理流程图:

 

 

 

二、本案需要使用如下第三方模块重新编译nginx:,各模块可以到nginx官方网站下载。

Upstream Keepalive– Provides keep-alive connections to Memcached upstreams.

Lua– Embed the power of Lua into Nginx.

Set Hash– Set a variable to a variety of hash functions (upper/lowercase), including MD5.

uWSGI– Allows Nginx  to interact with uWSGI  processes.

 

lai@debian:~/ua-detect-nignx/nginx# ls -l debian/modules/

total 32

drwxr-xr-x 6 root root 4096 2011-05-03 14:04 chaoslawful-lua-nginx-module

drwxr-xr-x 9 root root 4096 2011-04-16 16:19 nginx-development-kit

drwxr-xr-x 6 root root 4096 2011-04-16 16:19 nginx-echo

drwxr-xr-x 4 root root 4096 2011-04-16 16:19 nginx-http-push

drwxr-xr-x 2 root root 4096 2011-04-16 16:19 nginx-upstream-fair

drwxr-xr-x 3 root root 4096 2011-04-30 13:52 ngx_http_upstream_keepalive

drwxr-xr-x 2 root root 4096 2011-04-30 13:52 simpl-ngx_http_set_hash

-rw-r--r-- 1 root root  696 2011-03-22 11:13 versions

 

Nginx编译选选:

lai@debian:~/ua-detect-nignx/nginx# vi debian/rules 

111 config.status.extras: config.env.extras config.sub config.guess

112     cd $(BUILDDIR_extras) && ./configure /

113         --conf-path=/etc/nginx/nginx.conf /

114         --error-log-path=/var/log/nginx/error.log /

115         --http-client-body-temp-path=/var/lib/nginx/body /

116         --http-fastcgi-temp-path=/var/lib/ngin

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值