Nginx中include的具體用法
include可以用在任何地方,前提是include的文件自身語法正確。
include文件路徑可以是絕對路徑,也可以是相對路徑,相對路徑以nginx.conf為基準(zhǔn),同時可以使用通配符。
配置實例
# 絕對路徑 include /etc/conf/nginx.conf # 相對路徑 include port/80.conf # 通配符 include *.conf
測試配置文件
> ./nginx -t
主模式配置
user wwwt; # 服務(wù)器使用用戶 worker_processes 1; # 配置 worker 進程啟動的數(shù)量,建議配置為 CPU 核心數(shù) #error_log logs/error.log; # 全局錯誤日志 pid /etc/nginx/logs/nginx.pid; # 設(shè)置記錄主進程 ID 的文件 events { # 單個后臺 worker process 進程的最大并發(fā)鏈接數(shù) # 并發(fā)總數(shù) max_clients = worker_professes * worker_connections worker_connections 4096; ## Defaule: 1024 # multi_accept on; ## 指明 worker 進程立刻接受新的連接 } # 主模式 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; # 重點,分文件放置路徑 include /etc/nginx/cs/*.conf; #gzip on server { # the port your site will be served on listen 80; # the domain name it will serve for charset utf-8; # max upload size client_max_body_size 75M; # adjust to taste # Finally, send all non-media requests to the Django server. location / { } } }
分文件
server { # the port your site will be served on listen 443; # the domain name it will serve for server_name cs.oyz.cn; # substitute your machine's IP address or FQDN charset utf-8; ssl on; ssl_certificate cert/*****.pem; ssl_certificate_key cert/*****.key; # max upload size client_max_body_size 75M; # adjust to taste # Django media location /media { alias ********; # your Django project's media files - amend as required } location /static { alias ********; # your Django project's static files - amend as required } location / { uwsgi_param UWSGI_SCHEME https; uwsgi_pass 127.0.0.1:9002; uwsgi_send_timeout 3600s; # 指定向uWSGI傳送請求的超時時間,完成握手后向 uWSGI傳送請求的超時時間。 uwsgi_connect_timeout 3600s; # 指定連接到后端uWSGI的超時時間。 uwsgi_read_timeout 3600s; # 指定接收uWSGI應(yīng)答的超時時間,完成握手后接收uWSGI應(yīng)答的超時時間。 include /etc/nginx/uwsgi_params; # the uwsgi_params file you installed } }
到此這篇關(guān)于Nginx中include的具體用法的文章就介紹到這了,更多相關(guān)Nginx include內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
nginx rewrite 偽靜態(tài)配置參數(shù)詳細(xì)說明
nginx rewrite 偽靜態(tài)配置參數(shù)和使用例子 附正則使用說明2010-05-05nginx http響應(yīng)限速的具體實現(xiàn)
本文主要介紹了nginx http響應(yīng)限速的具體實現(xiàn),可以使用limite_rate和limit_rate_after來限制HTTP響應(yīng)的速度,具有一定的參考價值,感興趣的可以了解一下2024-05-05將樹莓派轉(zhuǎn)身為強大的Web服務(wù)器如何使用Nginx和cpolar實現(xiàn)遠程訪問
這篇文章主要介紹了Nginx可視化管理工具結(jié)合cpolar實現(xiàn)遠程訪問內(nèi)網(wǎng)服務(wù),相比其他 Web 服務(wù)器,Nginx 的內(nèi)存占用率非常低,可以在樹莓派等資源受限的設(shè)備上運行,同時結(jié)合cpolar 內(nèi)網(wǎng)穿透工具即可實現(xiàn)遠程訪問,需要的朋友可以參考下2023-09-09全面了解Nginx中的HTTP協(xié)議相關(guān)模塊配置
HTTP的處理是Nginx服務(wù)器的最重要功能,這里我們就帶大家來全面了解Nginx中的HTTP協(xié)議相關(guān)模塊配置,需要的朋友可以參考下2016-07-07Nginx+keepalived實現(xiàn)七層的負(fù)載均衡的高可用(最新解決方案)
這篇文章主要介紹了Nginx+keepalived實現(xiàn)七層的負(fù)載均衡的高可用,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2024-03-03