ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

NGINX加载多个COF文件配置

2026/9/27 8:52:13 拓冰建站 浏览量
NGINX加载多个COF文件配置
nginx.conf 总的配置
 
#############################################################
#
#          
#           nginx 反向代理设置,统一集管处,机器不够的话开集群。
#         包括:
#             SSL,限流,跨域,集群,黑名单,白名单,负载均衡
#
#############################################################user nginx;#指定进程数
worker_processes auto;#错误日志
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;#动态加载外部配置文件【inclue 路径 + *.conf 】
include /usr/share/nginx/modules/*.conf;#每个进程的最大连接数 
events {worker_connections 1024;
}http {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  /var/log/nginx/access.log  main;access_log  /wwwlogs/httpproxy.log  main;sendfile            on;tcp_nopush          on;tcp_nodelay         on;keepalive_timeout   65;types_hash_max_size 2048;include             /etc/nginx/mime.types;default_type        application/octet-stream;# Load modular configuration files from the /etc/nginx/conf.d directory.# See http://nginx.org/en/docs/ngx_core_module.html#include# for more information.# 加载配置include /etc/nginx/conf.d/*.conf;#加载upstream模块include /usr/share/nginx/ups_modules_http.conf;#加载http server 模块include /usr/share/nginx/http_servers/*.conf;    }stream {log_format proxy '$remote_addr [$time_local] ''$protocol $status $bytes_sent $bytes_received ''$session_time "$upstream_addr" ''"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';access_log /wwwlogs/tcp-access.log proxy;open_log_file_cache off;#挂载盘opt/nginx/conf/modulesinclude /usr/share/nginx/conf_servers/*.conf;
}

在con_server/可以配置多个 A系统.conf文件

server {listen 8888;location / { #通过代理将请求发送给 upstream 命名的HTTP 服务proxy_pass http://myserver;}}#定义一个 HTTP 服务组
upstream  myserver{#用server定义HTTP 地址。后面不写默认轮询。server 127.0.0.1:8081 max_fails=5 fail_timeout=10s weight=10;server 127.0.0.1:8082;server 127.0.0.1:8083;}
B系统conf文件
server {listen       80;server_name  127.0.0.1;location = /test {default_type text/html;return 200  'good';}
}