今天整理了下,在centos 7.6 系统下怎么配置多个conf文件。
step 1:在nginx.conf文件所在目录新建conf.d目录,即mkdir conf.d,为确保权限能够访问到
chmod 777 conf.d
step 2:编辑nginx.conf文件,内容为:
#user nobody;
worker_processes 1;error_log /usr/local/nginx/logs/error.log;
error_log /usr/local/nginx/logs/error.log notice;
error_log /usr/local/nginx/logs/error.log info;#pid logs/nginx.pid;events {
worker_connections 1024;
}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 /usr/local/nginx/logs/access.log main;sendfile on;
#tcp_nopush on;#keepalive_timeout 0;
keepalive_timeout 65;#gzip on;
include /usr/local/nginx/conf/conf.d/*.conf;}
step 3:在conf.d目录下随便写个.conf文件, 内容为:
upstream harbor-server{server 192.168.92.129:80;server 192.168.92.130:80;
}
server {listen 80;server_name harbor.gblfy.com;location / {proxy_pass http://harbor-server;}
}
step 4:测试下conf文件格式是否正确,nginx -t
step 5:启动nginx
step 6:浏览器输入地址访问