Skip to content

Instantly share code, notes, and snippets.

@rempargo
Last active December 16, 2020 13:15
Show Gist options
  • Save rempargo/25e27c9805ec61e633956c584d090f87 to your computer and use it in GitHub Desktop.
Save rempargo/25e27c9805ec61e633956c584d090f87 to your computer and use it in GitHub Desktop.
Get all domain names from Nginx as a ruby array
#ruby
# "server_name " include the whitespace to exclude non relevant results
# removes those server names that are commented
`sudo nginx -T | grep "server_name "`.gsub("server_name ","").delete("\t\n ").split(";").select{|domain|domain[0]!="#"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment