Skip to content

Instantly share code, notes, and snippets.

@DusterTheFirst
Last active June 15, 2019 15:59
Show Gist options
  • Save DusterTheFirst/7bbed82f6421df409939f2c1577d7a8d to your computer and use it in GitHub Desktop.
Save DusterTheFirst/7bbed82f6421df409939f2c1577d7a8d to your computer and use it in GitHub Desktop.
Create VHOSTS for lighttpd from a simple json file using only `include_shell "/usr/share/lighttpd/createLocalProxies.sh"`. So easy, elliot can use it.
#!/bin/sh
# Place in /usr/share/lighttpd/
FILENAME="/etc/lighttpd/localProxies.json"
cat $FILENAME\
| jq 'to_entries[] | .key as $host | .value | to_entries[] | {host: "\(.key).\($
| jq -r '
"else $HTTP[\"host\"] == \"\(.host)\" {
proxy.server = (\"\"=>((
\"host\"=>\"127.0.0.1\",
\"port\"=>\(.port)
)))
}"'\
| sed '1{s/^else //}; :a;N;$!ba;s/}\n/} /g'
// Place in /etc/lighttpd/
{
"elliotsworld.tech": {
"mcadmin": 8080,
"tf": 4299,
"amp": 8081,
"mc0": 8083,
"mc1": 8082,
"mc2": 8084
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment