<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Nginx配置文件詳解

      一、默認的Nginx配置文件nginx.conf內容如下:

      #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;
      
          #gzip  on;
      
          server {
              listen       80;
              server_name  localhost;
      
              #charset koi8-r;
      
              #access_log  logs/host.access.log  main;
      
              location / {
                  root   html;
                  index  index.html index.htm;
              }
      
              #error_page  404              /404.html;
      
              # redirect server error pages to the static page /50x.html
              #
              error_page   500 502 503 504  /50x.html;
              location = /50x.html {
                  root   html;
              }
      
              # proxy the PHP scripts to Apache listening on 127.0.0.1:80
              #
              #location ~ \.php$ {
              #    proxy_pass   http://127.0.0.1;
              #}
      
              # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
              #
              #location ~ \.php$ {
              #    root           html;
              #    fastcgi_pass   127.0.0.1:9000;
              #    fastcgi_index  index.php;
              #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
              #    include        fastcgi_params;
              #}
      
              # deny access to .htaccess files, if Apache's document root
              # concurs with nginx's one
              #
              #location ~ /\.ht {
              #    deny  all;
              #}
          }
      
      
          # another virtual host using mix of IP-, name-, and port-based configuration
          #
          #server {
          #    listen       8000;
          #    listen       somename:8080;
          #    server_name  somename  alias  another.alias;
      
          #    location / {
          #        root   html;
          #        index  index.html index.htm;
          #    }
          #}
      
      
          # HTTPS server
          #
          #server {
          #    listen       443 ssl;
          #    server_name  localhost;
      
          #    ssl_certificate      cert.pem;
          #    ssl_certificate_key  cert.key;
      
          #    ssl_session_cache    shared:SSL:1m;
          #    ssl_session_timeout  5m;
      
          #    ssl_ciphers  HIGH:!aNULL:!MD5;
          #    ssl_prefer_server_ciphers  on;
      
          #    location / {
          #        root   html;
          #        index  index.html index.htm;
          #    }
          #}
      
      }

       

      二、Nginx 文件結構

      ...              #全局塊
      
      events {         #events塊
         ...
      }
      
      http           #http塊
      {
          ...        #http全局塊

      upstream host_cluster { #upstream塊
      server ip1
      server ip2
      }
      server #server塊 { ... #server全局塊 location [PATTERN] #location塊 { ... } location [PATTERN] { ... } } server { ... } }
      • 1、全局塊:配置影響nginx全局的指令。一般有運行nginx服務器的用戶組,nginx進程pid存放路徑,日志存放路徑,配置文件引入,允許生成worker process數等。
      • 2、events塊:配置影響nginx服務器或與用戶的網絡連接。有每個進程的最大連接數,選取哪種事件驅動模型處理連接請求,是否允許同時接受多個網路連接,開啟多個網絡連接序列化等。
      • 3、http塊:可以嵌套多個server,配置代理,緩存,日志定義等絕大多數功能和第三方模塊的配置。如文件引入,mime-type定義,日志自定義,是否使用sendfile傳輸文件,連接超時時間,單連接請求數等。
      • 4、server塊:配置虛擬主機的相關參數,一個http中可以有多個server。
      • 5、location塊:配置請求的路由,以及各種頁面的處理情況。

       

      三、nginx.conf 配置文件示例詳解:

      ########### 每個參數配置末尾必須有分號 #################
      #user administrator administrators;  #配置用戶或者組,默認為nobody nobody。
      #worker_processes 2;  #允許生成的進程數,默認為1
      #pid /nginx/pid/nginx.pid;   #指定nginx進程運行文件存放地址
      error_log log/error.log debug;  #制定日志路徑,級別。這個設置可以放入全局塊,http塊,server塊,級別以此為:debug|info|notice|warn|error|crit|alert|emerg
      events {
          accept_mutex on;   #設置網路連接序列化,防止驚群現象發生,默認為on
          multi_accept on;  #設置一個進程是否同時接受多個網絡連接,默認為off
          #use epoll;      #事件驅動模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport
          worker_connections  1024;    #最大連接數,默認為512
      }
      http {
          include       mime.types;    #文件擴展名與文件類型映射表
          default_type  application/octet-stream;   #默認文件類型,默認為text/plain
          #access_log off;   #取消服務日志    
          log_format myFormat '$remote_addr–$remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for';  #自定義格式
          access_log log/access.log myFormat;   #combined為日志格式的默認值
          sendfile on;    #允許sendfile方式傳輸文件,默認為off,可以在http塊,server塊,location塊。
          sendfile_max_chunk 100k;   #每個進程每次調用傳輸數量不能大于設定的值,默認為0,即不設上限。
          keepalive_timeout 65;   #連接超時時間,默認為75s,可以在http,server,location塊。
      
          upstream mysvr {   
            server 127.0.0.1:7878;
            server 192.168.10.121:3333 backup;  #熱備
          }
          error_page 404 https://www.baidu.com;  #錯誤頁
          server {
              listen       80;       #nginx代理服務的端口,用戶訪問的端口
              server_name  localhost;      #nginx服務的域名或ip地址       
              location  ~*^.+$ {       #請求的url過濾,正則匹配,~為區分大小寫,~*為不區分大小寫。
                 #root path;   #根目錄
                 #index vv.txt;   #設置默認頁
                 proxy_pass  http://mysvr;      #請求轉向mysvr定義的服務器列表
                 deny 127.0.0.1;    #拒絕的ip
                 allow 172.18.5.54;   #允許的ip           
              } 
          }
      }

      上面是nginx的基本配置,需要注意的有以下幾點:

      1、幾個常見配置項:

      • 1.$remote_addr 與 $http_x_forwarded_for 用以記錄客戶端的ip地址
      • 2.$remote_user :用來記錄客戶端用戶名稱
      • 3.$time_local : 用來記錄訪問時間與時區
      • 4.$request : 用來記錄請求的url與http協議
      • 5.$status : 用來記錄請求狀態;成功是200
      • 6.$body_bytes_s ent :記錄發送給客戶端文件主體內容大小
      • 7.$http_referer :用來記錄從那個頁面鏈接訪問過來的
      • 8.$http_user_agent :記錄客戶端瀏覽器的相關信息

      2、驚群現象:一個網路連接到來,多個睡眠的進程被同時喚醒,但只有一個進程能獲得連接,這樣會影響系統性能。

      3、每個參數配置末尾必須有分號。

       

      四、location匹配規則

      1、nginx官方文檔給出的location語法如下: 

      location  [=|~|~*|^~]  uri  {

          ···

      }

      其中,方括號中的四種標識符是可選項,用來改變請求字符串和uri的匹配方式。uri是待匹配的請求字符串,可以是不包含正則的字符串,這種模式被稱為“標準的uri";也可以包含正則,這種模式被稱為"正則uri"。

       

      2、幾種可選的標識符:

      =:精確匹配,精確匹配等號后面的URI.

      /abc:模糊匹配,匹配以/abc開頭的URI,例如/abcd、/abc/demo等.

      /:通用匹配,如果沒有其它匹配規則,任何請求都會匹配到這里.

      ~:正則匹配(區分大小寫).

      ~*:正則匹配(不區分大小寫).

      ^~:帶參前綴匹配(匹配到就停止后面的).

       

      posted @ 2022-09-27 18:10  陳彬Alick  閱讀(271)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 亚洲精品视频免费| free性开放小少妇| 亚洲成人免费一级av| 久久久婷婷成人综合激情| 亚洲精品第一区二区三区| 亚洲中文精品一区二区| 亚洲人成小说网站色在线| 国产成人亚洲日韩欧美| 丰满少妇呻吟高潮经历| 蜜桃久久精品成人无码av | 日韩国产成人精品视频| AV最新高清无码专区| 毛茸茸性xxxx毛茸茸毛茸茸| 久久天天躁狠狠躁夜夜不卡| 亚洲中文字幕国产综合| 2021亚洲国产精品无码| 精品亚洲国产成人| 午夜精品久久久久久久久| 污网站在线观看视频| 亚洲爆乳精品无码一区二区| 国产一区二区三区不卡观| 亚洲一区中文字幕人妻| 国产AV无码专区亚洲AV潘金链| 国产av日韩精品一区二区| 亚洲一区二区三区在线| 国产欧美日韩精品丝袜高跟鞋| 日本高清一区二区三| 亚洲天堂在线观看完整版| 热久久美女精品天天吊色| 俄罗斯少妇性XXXX另类| 在线观看视频一区二区三区| 国产成人精品aa毛片| 国产亚洲一级特黄大片在线| 欧美成人精品三级在线观看| 香蕉EEWW99国产精选免费| 亚洲天堂一区二区成人在线| 国产亚洲精品第一综合| 国产日韩精品免费二三氏| 在线播放亚洲成人av| 午夜在线观看成人av| 亚洲精品亚洲人成人网|