Nginx中include的具體用法
include可以用在任何地方,前提是include的文件自身語(yǔ)法正確。
include文件路徑可以是絕對(duì)路徑,也可以是相對(duì)路徑,相對(duì)路徑以nginx.conf為基準(zhǔn),同時(shí)可以使用通配符。
配置實(shí)例
# 絕對(duì)路徑 include /etc/conf/nginx.conf # 相對(duì)路徑 include port/80.conf # 通配符 include *.conf
測(cè)試配置文件
> ./nginx -t

主模式配置
user wwwt; # 服務(wù)器使用用戶(hù)
worker_processes 1; # 配置 worker 進(jìn)程啟動(dòng)的數(shù)量,建議配置為 CPU 核心數(shù)
#error_log logs/error.log; # 全局錯(cuò)誤日志
pid /etc/nginx/logs/nginx.pid; # 設(shè)置記錄主進(jìn)程 ID 的文件
events {
# 單個(gè)后臺(tái) worker process 進(jìn)程的最大并發(fā)鏈接數(shù)
# 并發(fā)總數(shù) max_clients = worker_professes * worker_connections
worker_connections 4096; ## Defaule: 1024
# multi_accept on; ## 指明 worker 進(jìn)程立刻接受新的連接
}
# 主模式
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;
# 重點(diǎn),分文件放置路徑
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傳送請(qǐng)求的超時(shí)時(shí)間,完成握手后向 uWSGI傳送請(qǐng)求的超時(shí)時(shí)間。
uwsgi_connect_timeout 3600s; # 指定連接到后端uWSGI的超時(shí)時(shí)間。
uwsgi_read_timeout 3600s; # 指定接收uWSGI應(yīng)答的超時(shí)時(shí)間,完成握手后接收uWSGI應(yīng)答的超時(shí)時(shí)間。
include /etc/nginx/uwsgi_params; # the uwsgi_params file you installed
}
}到此這篇關(guān)于Nginx中include的具體用法的文章就介紹到這了,更多相關(guān)Nginx include內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Linux系統(tǒng)下nginx日志每天定時(shí)切割的腳本寫(xiě)法
本篇文章給大家分享使用Linux系統(tǒng)自帶的命令logrotate對(duì)Nginx日志進(jìn)行切割的方法,對(duì)nginx日志切割腳本感興趣的朋友一起學(xué)習(xí)吧2016-11-11
nginx中調(diào)度算法的五種實(shí)現(xiàn)
本文主要介紹了nginx中調(diào)度算法的五種實(shí)現(xiàn),包括輪詢(xún)、權(quán)重輪詢(xún)、IP哈希、fair和URL哈希,具有一定的參考價(jià)值,感興趣的可以了解一下2025-03-03
使用nginx正向代理實(shí)現(xiàn)訪(fǎng)問(wèn)外網(wǎng)
這篇文章主要介紹了使用nginx正向代理實(shí)現(xiàn)讓內(nèi)網(wǎng)主機(jī)通過(guò)外網(wǎng)主機(jī)訪(fǎng)問(wèn)外網(wǎng),文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-12-12
阿里云ssl證書(shū)如何通過(guò)Nginx部署到服務(wù)器
這篇文章主要介紹了阿里云ssl證書(shū)通過(guò)Nginx部署到服務(wù)器的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-03-03
Nginx使用ngx_http_upstream_module實(shí)現(xiàn)負(fù)載均衡功能示例
本文主要介紹了Nginx使用ngx_http_upstream_module實(shí)現(xiàn)負(fù)載均衡功能示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08
Nginx服務(wù)器中強(qiáng)制使用緩存的配置及緩存優(yōu)先級(jí)的講解
這篇文章主要介紹了Nginx服務(wù)器中強(qiáng)制使用緩存的配置及緩存優(yōu)先級(jí)的講解,一定程度上可以幫助大家解決Nginx不緩存或緩存失效的問(wèn)題,需要的朋友可以參考下2016-01-01
使用LDAP實(shí)現(xiàn)Nginx用戶(hù)認(rèn)證的示例
本文主要使用Nginx和LDAP實(shí)現(xiàn)用戶(hù)認(rèn)證,通過(guò)配置Nginx和安裝nginx-auth-ldap模塊,可以實(shí)現(xiàn)基于LDAP的認(rèn)證邏輯,下面就來(lái)介紹一下,感興趣的可以了解一下2024-12-12

