Nginx主配置參數(shù)詳解,Nginx配置網(wǎng)站

Niginx主配置文件參數(shù)詳解

成都創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計、波密網(wǎng)絡(luò)推廣、小程序設(shè)計、波密網(wǎng)絡(luò)營銷、波密企業(yè)策劃、波密品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們大的嘉獎;成都創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供波密建站搭建服務(wù),24小時服務(wù)熱線:18980820575,官方網(wǎng)址:muchs.cn

當(dāng)Nginx安裝完畢后,會有相應(yīng)的安裝目錄,安裝目錄里的nginx.confg為nginx的主配置文件,nginx主配置文件分為4部分,main(全局配置)、server(主機配置)、upstream(負(fù)載均衡服務(wù)器設(shè)置)以及l(fā)ocation(URL匹配特定位置的設(shè)置),這四者的關(guān)系是:server繼承main,location繼承server,upstream既不會繼承其它設(shè)置也不會被繼承。

Nginx.conf配置文件詳細(xì)說明(附備注)

# kencery 注釋說明Nginx文件 # 時間:2016-1-19 # 學(xué)習(xí)內(nèi)容,只是來自互聯(lián)網(wǎng),有版權(quán)問題請聯(lián)系我刪除。 ######## Nginx的main(全局配置)文件 #指定nginx運行的用戶及用戶組,默認(rèn)為nobody #user nobody; #開啟的線程數(shù),一般跟邏輯CPU核數(shù)一致 worker_processes 1; #定位全局錯誤日志文件,級別以notice顯示,還有debug,info,warn,error,crit模式,debug輸出最多,crir輸出最少,根據(jù)實際環(huán)境而定 #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #指定進程id的存儲文件位置 #pid logs/nginx.pid; #指定一個nginx進程打開的最多文件描述符數(shù)目,受系統(tǒng)進程的打開文件數(shù)量限制 #worker_rlimit_nofile 65535 events { #設(shè)置工作模式為epoll,除此之外還有select,poll,kqueue,rtsig和/dev/poll模式 #use epoll; #定義每個進程的連接數(shù),受系統(tǒng)進程的打開文件數(shù)量限制。 worker_connections 1024; } #######Nginx的Http服務(wù)器配置,Gzip配置 http { #主模塊指令,實現(xiàn)對配置文件所包含的文件的設(shè)定,可以減少主配置文件的復(fù)雜度,DNS主配置文件中的zonerfc1912,acl基本上都是用include語句。 include mime.types; #核心模塊指令,智力默認(rèn)設(shè)置為二進制流,也就是當(dāng)文件類型未定義時使用這種方式 default_type application/octet-stream; #下面代碼為日志格式的設(shè)定,main為日志格式的名稱,可自行設(shè)置,后面引用 #log_format main \'$remote_addr - $remote_user [$time_local] "$request" \' # \'$status $body_bytes_sent "$http_referer" \' # \'"$http_user_agent" "$http_x_forwarded_for"\'; #引用日志main #access_log logs/access.log main; #設(shè)置允許客戶端請求的的單個文件字節(jié)數(shù) #client_max_body_size 20M; #指定來自客戶端請求頭的headebuffer大小 #client_header_buffer_size 32k; #指定連接請求試圖寫入緩存文件的目錄路徑 #client_body_temp_path /dev/shm/client_body_temp; #指定客戶端請求中較大的消息頭的緩存數(shù)量和大小,目前設(shè)置為4個32KB #large client_header_buffers 4 32k; #開啟高效文件傳輸模式 sendfile on; #開啟防止網(wǎng)絡(luò)阻塞 #tcp_nopush on; #開啟防止網(wǎng)絡(luò)阻塞 #tcp_nodelay on; #設(shè)置客戶端連接保存活動的超時時間 #keepalive_timeout 0; keepalive_timeout 65; #設(shè)置客戶端請求讀取超時時間 #client_header_timeout 10; #設(shè)置客戶端請求主體讀取超時時間 #client_body_timeout 10; #用于設(shè)置相應(yīng)客戶端的超時時間 #send_timeout ####HttpGZip模塊配置 #httpGzip modules #開啟gzip壓縮 #gzip on; #設(shè)置允許壓縮的頁面最小字節(jié)數(shù) #gzip_min_length 1k; #申請4個單位為16K的內(nèi)存作為壓縮結(jié)果流緩存 #gzip_buffers 4 16k; #設(shè)置識別http協(xié)議的版本,默認(rèn)為1.1 #gzip_http_version 1.1; #指定gzip壓縮比,1-9數(shù)字越小,壓縮比越小,速度越快 #gzip_comp_level 2; #指定壓縮的類型 #gzip_types text/plain application/x-javascript text/css application/xml; #讓前端的緩存服務(wù)器進過gzip壓縮的頁面 #gzip_vary on; #########Nginx的server虛擬主機配置 server { #監(jiān)聽端口為 80 listen 80; #設(shè)置主機域名 server_name localhost; #設(shè)置訪問的語言編碼 #charset koi8-r; #設(shè)置虛擬主機訪問日志的存放路徑及日志的格式為main #access_log logs/host.access.log main; #設(shè)置虛擬主機的基本信息 location / { #設(shè)置虛擬主機的網(wǎng)站根目錄 root html; #設(shè)置虛擬主機默認(rèn)訪問的網(wǎng)頁 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代理網(wǎng)站

修改Nginx的配置文件,修改命令:vim /etc/nginx/nginx.conf

upstream console { server 10.51.2.237:8083 weight=1; }

location /index { proxy_pass http://console/index; }

先測試配置是否正確,再重啟nginx服務(wù)

./nginx -t ./nginx -s reload

文章名稱:Nginx主配置參數(shù)詳解,Nginx配置網(wǎng)站
本文鏈接:http://muchs.cn/article44/chsiee.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、定制網(wǎng)站、網(wǎng)站排名微信小程序、虛擬主機、網(wǎng)站維護

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)