<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # nginx案例-不同客戶端顯示不同信息 [TOC] ## 一、需求梳理: 1. 需求 根據用戶請求客戶端軟件不同,顯示不同頁面信息,常見為手機端和網頁端界面排版會不一樣 2. 資源池 |用戶請求[URI]|處理請求服務器|站點目錄|功能| | --- | --- | --- | --- | |/|10.0.0.8:80|html/www/|iphone服務器| |/|10.0.0.7:80|html/www/|android服務器| |/|10.0.0.9:80|html/www/|pc服務器| 3. 環境搭建 ```sh yum install nginx -y egrep -v "#|^$" /etc/nginx/nginx.conf.default >/etc/nginx/nginx.conf mkdir -p /data/html/www cp /usr/share/nginx/html/* /data/html/www sed -ri '/^$|#/d' /etc/nginx/nginx.conf sed -ri '/^$|#/d' /etc/nginx/conf.d/default.conf 省 ``` ## 二、解決方法: ### 1. 完成nginx網站服務器配置 **創建測試環境** 10.0.0.8 主機上生成網站測試頁面文件 ```sh mkdir -p /data/html/www/upload echo "test in Ip 10.0.0.8 is iPhone page" >/data/html/www/noah.html ``` 10.0.0.7 主機上生成網站測試頁面文件 ```sh mkdir -p /data/html/www/static echo "test in Ip 10.0.0.7 is Android page" >/data/html/www/noah.html ``` 10.0.0.9 主機上生成測試頁面文件即可 ```sh echo "test in Ip 10.0.0.9 is pc page" >/data/html/www/noah.html ``` ### 2. 利用lb01進行訪問測試 測試10.0.0.8訪問是否正常 ```sh [root@xxx~]# curl -H host:www.etiantian.org 10.0.0.8/noah.html test in Ip 10.0.0.8 is iPhone page ``` 測試10.0.0.7訪問是否正常 ```sh [root@xxx~]# curl -H host:www.etiantian.org 10.0.0.7/noah.html test in Ip 10.0.0.7 is Android page ``` 測試10.0.0.9訪問是否正常 ```sh [root@xxx~]# curl -H host:www.etiantian.org 10.0.0.9/noah.html test in Ip 10.0.0.7 is pc page ``` ### 3.完成nginx反向代理服務器配置 **配置upstream模塊信息** ```sh upstream iphone { server 10.0.0.8:80; } upstream android { server 10.0.0.7:80; } upstream pc { server 10.0.0.9:80; } ``` **配置proxy_pass模塊信息** ```sh server { listen 80; server_name www.etiantian.org; root html; index index.html index.htm; location / { if ($http_user_agent ~* "iphone") { proxy_pass http://iphone; } if ($http_user_agent ~* "android") { proxy_pass http://android; } proxy_pass http://pc; proxy_set_header host $host; proxy_set_header X-Forwarded-For $remote_addr; } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看