Skip to content

shi-gg/proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

P R O X Y

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.

Setup

  1. Clone this repository using git clone https://github.com/Luna-devv/proxy
  2. Adapt the src/hosts.ts to your needs and webservers
  3. Install all external dependencies using npm install or yarn install
  4. Compile the code using npx tsc
  5. Run the script with PM2 pm2 start dist/app.js --name proxy

Modify records

Example key for proxing a webserver:

{
    "api.waya.one": {
        target: 4000,
        type: "WEB",
        arc: false
    }
}

key ("api.waya.one")

This will be the subdomain or the domain that will be proxied.

target

  • (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")

type

There are 3 essential types:

  • "WEB": You will use this if you want that for example the content of the page 123.456.789:4000 should be displayed on api.waya.one.
  • "WS": You will use this if you have a (server) websocket and you want i.e. to forward it from 123.456.789:4000 to api.waya.one.
  • "REDIRECT": YOu will use this if you want to redirect the user to another page, this requires setting target to a string.

arc

If your site is using arc.io you can just set this value to true to enable support for it.
Note: All requests to /arc-sw.js will be catched by the proxy and will NOT reach your webserver.

Modify error pages

If you want to to change the error pages for either a missing record (404.html) or the page for a not responding webserver (500.html), go to the /html/ file tree and start editing your plain HTML pages there.
Note: There is a {hosts} placeholder that will be replaced with the requested domain (i.e.: api.waya.one)

Any questions left?

Feel free to open a issue, send me an E-Mail or join my Discord server.