Basic proxy script written in node.js using node:http and node-http-proxy.
This script was originally written from @flamexdev and was improved and re-written into TypeScript by me.
A full walk trough can be found on this GitHub's Wiki.
- Clone this repository using
git clone https://github.com/Luna-devv/proxy
- Adapt the
src/hosts.ts
to your needs and webservers - Install all external dependencies using
npm install
oryarn install
- Compile the code using
npx tsc
- Run the script with PM2
pm2 start dist/app.js --name proxy
Example object for proxing a webserver:
{
"proxy.local": {
target: 3000,
type: "WEB"
}
}
This value can only be a String, this key is required.
This will be the subdomain (subdomain.proxy.local
) or the domain (proxy.local
) that will be managed.
This value can only be a String, this key is required.
- (using
"WEB"
or"WS"
): This is the port on which your webserver runs. Please note that this musst run on the same server as this proxy script. - (using
"REDIRECT"
): This is the domain/IP the proxy script will redirect to. Note that this can be any domain, it must include the protocal (i.e."https://lunish.nl/luna"
)
This value can only be WEB
, WS
or REDIRECT
, this key is required.
There are 3 essential types:
"WEB"
: You will use this if you want that for example the content of the page123.456.789:4000
should be displayed onapi.waya.one
."WS"
: You will use this if you have a (server) websocket and you want i.e. to forward it from123.456.789:4000
toapi.waya.one
."REDIRECT"
: YOu will use this if you want to redirect the user to another page, this requires settingtarget
to a string.
Please read the wiki at https://github.com/Luna-devv/proxy/wiki
Feel free to open a issue, send me an E-Mail or join my Discord server.