如何在Nginx中列出所有虚拟主机 [英] How can I list all vhosts in nginx

查看:123
本文介绍了如何在Nginx中列出所有虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有命令列出所有在CentOS上的Nginx下运行的虚拟主机或服务器?我希望将结果通过管道传输到文本文件中以进行报告.

Is there a command that will list all vhosts or servers running under nginx on CentOS? I would like to pipe the results to a text file for reporting purposes.

我正在寻找类似于我用于Apache的命令的内容:

I'm looking for something similar to this command that I use for Apache:

apachectl -S 2>& 1 | grep'端口80'

apachectl -S 2>&1 | grep 'port 80'

推荐答案

更新: 感谢@Putnik指出了一种更简单的方法(但我更喜欢仅列出启用了网站的内容):

Update: Thanks to @Putnik for pointing out an easier way (but I prefer only listing sites-enabled):

grep server_name /etc/nginx/sites-enabled/* -RiI


旧帖子:

尝试这样的事情:

find /etc/nginx/sites-enabled/ -type f -print0 | xargs -0 egrep '^(\s|\t)*server_name'

希望有帮助!

这篇关于如何在Nginx中列出所有虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆