From 4cc77eea8b2cbfd511441ad7373018c947764de0 Mon Sep 17 00:00:00 2001 From: dig Date: Sat, 22 Dec 2018 02:50:45 +0100 Subject: [PATCH] mini doc --- README.md | 21 +++++++++++++- domains-exemple | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 domains-exemple diff --git a/README.md b/README.md index 3fde892..d0f3fa5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,22 @@ # yxorp -Simple reverse proxy | yxorp esrever elpmiS \ No newline at end of file +Simple reverse proxy | yxorp esrever elpmiS + +Listen http request on one port and redirect to another app server on +specific ports defined in a config file. + + +## Usage + +```bash +yxorp my_config_file +``` + +Defaults to port 80. + +To specify the port: +```bash +yxorp -p8080 my_config_file +``` + +See `domains-exemple` and `tests/domains-test` for domain file syntax. diff --git a/domains-exemple b/domains-exemple new file mode 100644 index 0000000..ac1b658 --- /dev/null +++ b/domains-exemple @@ -0,0 +1,76 @@ +# Line beginning with or text after '#' until the end of line are comments and ignored +# Each line is parsed and splitted by space|tab +# Each line have to be 2 columns, +# one for source [required] and one for destination [optional] +# A line with only a source element act as a master domain +# A line with the source ending with '.' is a subdomain for preceding master domain +# First match wins! Keep the less specific tests last + + +# Equivalent + +www.exemple.com 8080 + www.exemple.com 8080 + www.exemple.com 8080 + www.exemple.com 8080 # some reminder + + +# Master domain, subdomains + + exemple.com # the master domain + . 8080 # http://exemple.com + www. 8080 # http://www.exemple.com + sub1. 9888 # http://sub1.exemple.com + subdomain. 9169 # http://subdomain.exemple.com + sub2. 3333 # http://sub2.exemple.com + + +# Wildcards tests + + foo*.exemple.com 6476 # foobar.exemple.com or foolish.exemple.com + www.my-*-site.com 5740 # www.my-cool-site.com or www.my-bad-site.com + exemple.* 23456 # exemple.fr or exemple.de or exemple.org + + exemple.com + tag-*. 1111 # tag-music.exemple.com + *---*. 2222 # awe---some.exemple.com + *. 3333 # less specific last: toto.exemple.com + + admin.* 6666 # no more under exemple.com: admin.google.fr or admin.my-site.net + + +# Regexp tests (must start and end with a '/') + + /exemple\.(fr|de|it|com)/ 8888 # don't forget to escape regexp chars like '.' + /(.*?)\.exemple\.com/ 4567 # all javascript regexp are correct +/(.*?)-+(coin|token)\.exemple\.com/ 443 # parenthesis capture can be used later (see rewriting) + + exemple\.(fr|de|it|com)/ # to mix regexp and master domain you can cut the reg in 2 + # subdomains still have to end with '.' + /some.{3,5}\. 1234 # something.exemple.de or somehow.exemple.com + /other.{4}\. 3456 # otherwise.exemple.fr or otherhood.exemple.it + + +# Rewriting url using es6 string substitutions `Hello ${who} !` +# /!\ spaces are prohibited in substitution ! + + # using precooked variables: subDomain, domain, tld, path + + www.exemple.com 8080/${domain}/www/ # 8080/exemple/www/ + www.exemple.com 8080/${tld}-${domain}/${subDomain}/ # 8080/com-exemple/www/ + *.exemple.com 6757/static/${subDomain}-files/${path} # 6757/static/www-files/... or 6757/static/img-files/... + + # using regexp captures (wildcards are converted into regexp also) + + exemple.com + tag-*. 6776/tags/${match[1]}/ + *---*. ${match[1]=='foo'?6666:6667}/apps/${match[2]}/ + *. 6776/${match[1]}-files/ + www.exemple.* 80/lang/${tld}/ + admin.* 6666/${domain=='exemple'?'docs':'administration'}/${domain}-${tld}/ + +/(foo)-(bar)\.exemple\.city/ 31316/tag/${match[2]}-${match[1]}/ + *.exemple.city 31316/city/${subDomain}/ + + +