Nginx基本的WEB配置

#user administrator administrators;  #配置用戶或者組,默認(rèn)為nobody nobody。
#worker_processes 2;  #允許生成的進(jìn)程數(shù),默認(rèn)為1
#pid /nginx/pid/nginx.pid;   #指定nginx進(jìn)程運(yùn)行文件存放地址
error_log log/error.log debug;  #制定日志路徑,級(jí)別。這個(gè)設(shè)置可以放入全局塊,http塊,server塊,級(jí)別以此為:debug|info|notice|warn|error|crit|alert|emerg
events {
    accept_mutex on;   #設(shè)置網(wǎng)路連接序列化,防止驚群現(xiàn)象發(fā)生,默認(rèn)為on
    multi_accept on;  #設(shè)置一個(gè)進(jìn)程是否同時(shí)接受多個(gè)網(wǎng)絡(luò)連接,默認(rèn)為off
    #use epoll;      #事件驅(qū)動(dòng)模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport
    worker_connections  1024;    #最大連接數(shù),默認(rèn)為512
}
http {
    include       mime.types;   #文件擴(kuò)展名與文件類型映射表
    default_type  application/octet-stream; #默認(rèn)文件類型,默認(rèn)為text/plain
    #access_log off; #取消服務(wù)日志    
    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為日志格式的默認(rèn)值
    sendfile on;   #允許sendfile方式傳輸文件,默認(rèn)為off,可以在http塊,server塊,location塊。
    sendfile_max_chunk 100k;  #每個(gè)進(jìn)程每次調(diào)用傳輸數(shù)量不能大于設(shè)定的值,默認(rèn)為0,即不設(shè)上限。
    keepalive_timeout 65;  #連接超時(shí)時(shí)間,默認(rèn)為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; #錯(cuò)誤頁
    server {
        keepalive_requests 120; #單連接請(qǐng)求上限次數(shù)。
        listen       4545;   #監(jiān)聽端口
        server_name  127.0.0.1;   #監(jiān)聽地址       
        location  ~*^.+$ {       #請(qǐng)求的url過濾,正則匹配,~為區(qū)分大小寫,~*為不區(qū)分大小寫。
           #root path;  #根目錄
           #index vv.txt;  #設(shè)置默認(rèn)頁
           proxy_pass  http://mysvr;  #請(qǐng)求轉(zhuǎn)向mysvr 定義的服務(wù)器列表
           deny 127.0.0.1;  #拒絕的ip
           allow 172.18.5.54; #允許的ip           
        } 
    }
} 
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容