This project provides a simple HTTP server that can be configured to redirect each root path to a unique endpoint on a single address.
I use this to easily access local servers and services on my home network. I have a go-server running on an LXC container with entries pointing to my router, NAS, media server, hypervisors, pihole, etc. Using a local DNS entry to takeover the go.to domain and point it to my go-server (thru pihole), I am now able to access my local servers in a browser by simply typing go.to/plex or go.to/pihole for example.
Configuration is handled as a single endpoints.json file. This is a JSON object with each key representing a unique subpath. A special entry with key / is used to control behavior on the root page. Each object in the dictionary has an action field used to specify what action should be taken when a user navigates to that page.
reload: Causes theendpoints.jsonfile to be reloaded on the server.redirect: Causes a redirect to occur for the user. Must specify aredirect_urlvalue to be used.static: Responds with a static file for a given route. Must specify afile_pathvalue to be used.- ...more coming soon!
{
"/": {
"action": "static",
"file_path": "./endpoints.json"
},
"reload": {
"action": "reload"
},
"router": {
"action": "redirect",
"redirect_url": "https://192.168.1.1"
},
"plex": {
"action": "redirect",
"redirect_url": "https://192.168.1.150:8006"
}
}The above sample configuration defines four (4) unique endpoints available at server (static endpoint), server/reload (reload endpoint), server/router (redirect endpoint), and server/plex (redirect endpoint).
- Endpoints must be specified in all lowercase.
- Do not prepend a
/to any endpoints.
- Clone this repository or download the zip bundle:
git clone https://github.com/EvilKanoa/go-server.git - Install NodeJS 12+
- Run
npm installto fetch all required dependencies. - Configure
endpoints.jsonas explained above. - Run
npm startto start the server. - You can reload the
endpoints.jsonfile by specifying thereloadaction for a given route and then navigating to that route.