从nginx配置中找出相关域名

2021-05-18 10:05:59 浏览数 (1)

#!/bin/sh

set -x

#serverlist=`ls -l /usr/local/nginx/conf/vhost/*.conf | awk -F" " '{print $7}'`

serverlist=`ls -l /usr/local/nginx/conf/vhost/*.conf | awk 'NR>2{print $NF}'`

for i in $serverlist;do

grep -ir "server_name" $serverlist | awk -F"server_name" '{print $2}' >> server.txt

done

sort -n server.txt |uniq

grep -ir "server_name" /usr/local/nginx/conf/nginx.conf | awk -F"server_name" '{print $2}'

0 人点赞