NGINX加载多个COF文件配置

发布时间:2023年12月29日
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/modules
    include /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';
    }
}
文章来源:https://blog.csdn.net/weixin_43840872/article/details/135290201
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。