<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] ## TCP反向代理 ***** nginx1.9開始支持tcp層的轉發,通過stream實現的,。 默認yum安裝的Nginx不支持TCP轉發,需要安裝--with-stream 模塊,可以通過源碼編譯安裝這個模塊后替換原來的nginx執行程序。 ### Linux環境安裝Nginx --with-stream模塊 ***** 下載一個同版本可編譯的Nginx ``` $ wget http://nginx.org/download/nginx-1.16.0.tar.gz ``` 安裝缺少的庫 ``` yum install -y openssl-devel.x86_64 pcre-devel.x86_64 ``` 解壓并進入目錄: ``` $ tar xvf nginx-1.16.0.tar.gz $ cd nginx-1.16.0 ``` 編譯安裝--with-stream 模塊 ``` $ ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/usr/local/nginx16/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --with-stream $ make $ make install ``` 驗證模塊安裝情況 ``` /usr/local/nginx/nginx -V ``` ### TCP轉發配置 ***** 創建文件夾和配置 cd /etc/nginx mkdir tcp.d 修改配置文件包含文件 vi /etc/nginx/nginx.conf,增加如下行 ``` stream { include /etc/nginx/tcp.d/*.conf; } ``` 創建tcp反向代理配置文件 vi /etc/nginx/tcp.d/testdb_proxy.conf,增加如下內容 ``` stream { upstream testdb_proxy { hash $remote_addr consistent; # 轉發的目的地址和端口 server 10.168.240.239:1521 weight=5 max_fails=3 fail_timeout=30s; } # 提供轉發的服務,即訪問localhost:8921,會跳轉至代理testdb_proxy指定的轉發地址 server { listen 8921; proxy_connect_timeout 1s; proxy_timeout 3s; proxy_pass testdb_proxy; } } ``` 如果需要tcp長連接則: ``` server { listen 8921 so_keepalive=on; proxy_connect_timeout 1s; proxy_timeout 3s; proxy_pass testdb_proxy; } ``` 增加日志: ``` log_format proxy '$remote_addr [$time_local] ' '$protocol $status $bytes_sent $bytes_received ' '$session_time "$upstream_addr" ' '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"'; access_log /var/log/nginx/tcp-access.log proxy ; open_log_file_cache off; include /etc/nginx/conf.d/*.stream; ``` 啟動nginx ``` nginx -c /etc/nginx/nginx.conf ``` ### Upstream upstream 就是負載均衡。從字面上的意思就可以理解,負載均衡就是均衡的,按照特定的調度算法,將請求調度到指定的節點(**upstream server**)。 **upstream**配置說明: 1. nginx 負載均衡調度算法加上我們安裝的 fair 模塊,大致有以下 4 種: | 調度算法 | 說明 | | --- | --- | | 權重輪詢(默認) | 按照順序逐一分配到不同的后端。自動剔除失敗的機器,使訪問不受影響。 | | ip_hash| 每個請求按照 IP 的 Hash 結果分配,使來自同一 IP 的固定訪問到同一后端。能解決部分程序 session 沒共享的問題| | fair| 更智能的算法,可以根據頁面大小和加載速度進行智能負載,響應快的優先分配。| | url_hash| 需要按照 nginx hash 模塊,按照訪問的 URL 定向到某個機器上,能提升后端緩存服務器的效率。| ## linux 添加用戶組,添加用戶 ***** 1、建用戶: ``` adduser nginx???????????????????????????? //新建phpq用戶 passwd nginx?????????????????????????????? //給phpq用戶設置密碼 ``` 2、建工作組 ``` groupadd test????????????????????????? //新建test工作組 ``` 3、新建用戶同時增加工作組 ``` useradd -g test phpq????????????????????? //新建phpq用戶并增加到test工作組 ``` 注::-g 所屬組 -d 家目錄 -s 所用的SHELL ## Http反向代理 *****
                  <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>

                              哎呀哎呀视频在线观看