Nginx配置根据客户端设备转发

Posted 谭普利特

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx配置根据客户端设备转发相关的知识,希望对你有一定的参考价值。

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  $remote_addr - $remote_user [$time_local] "$request" 
                      $status $body_bytes_sent "$http_referer" 
                      "$http_user_agent" "$http_x_forwarded_for";

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    upstream static_pools {
        server 192.168.56.13;

        }
    upstream  upload_pools {
        server 192.168.56.14;

        }
    #gzip  on;

    server {
        listen       80;
        server_name  localhost;
        root /Data/www;

        location / {
                if ($http_user_agent ~* "MSIE") {
                        proxy_pass http://static_pools;
                                }
                if ($http_user_agent ~* "chrome") {
                        proxy_pass http://upload_pools;
                                        }
#               if ($http_user_agent ~* "Firefox") {
#                       proxy_pass http://xxx_pools;
#                               }
#安卓:android 苹果:iphone
           index index.html; } error_page
500 502 503 504 /50x.html; location = /50x.html { root html; } } }

 



以上是关于Nginx配置根据客户端设备转发的主要内容,如果未能解决你的问题,请参考以下文章

nginx 配置模板

Nginx安装配置说明

nginx根据域名转发

nginx配置根据url的参数值进行转发

nginx反向代理功能及常用配置

nginx http_realip_module 被高级安全防护设备代理后,获取用户端真实IP,并通过真实IP负载均衡转发到后端应用