- nodejs (tested on v18 and v20, older nodejs might not work)
- npm
- mariadb (do not use mysql because it use some mariadb specific syntax which are not compatible with mysql)
- redis (to save session data)
- modern linux distribution (2023)
git clone https://github.com/kucingbasah737/redirector.git
cd redirector
npm ci
Do not run "npx db-migrate up" at this step before you create correct .env file.
Please copy "sample.env" file to ".env" file and change with your configurations.
Create user and database to use on your mariadb server, and don't forget to change database these parameters on **.env" file:
MYSQL_SOCKET_PATH=
MYSQL_HOST=
MYSQL_PORT=
MYSQL_DATABASE=
MYSQL_USER=
MYSQL_PASSWORD=
MYSQL_SOCKET_PATH is optional but recommended.
After you make adjustment on .env, run this to init database schema:
npx db-migrate up
You must register hostnames to serve by this redirector service by running:
./index.js insert-hostname
You can list registered hostnames by running:
./index.js hostname-list
Make sure you have modified .env file to match your environtment.
npm run dev
npm start
Open your browser and open the url using specified port at WEB_PORT environment variable. Default user is admin and default password is admin.
You can change user password by running:
./index.js update-password
And to add a new user:
./index.js add-user
npm run update
NOTE: You MUST update the data files after installation. The MaxMind license does not allow us to distribute the latest version of the data files with this package.
To update GeoLite database, please set MAXMIND_LICENSE_KEY on .env file, and then run:
./update-geoip-database.sh
Set "WEB_TRUST_PROXY=" on your .env file. Example:
WEB_TRUST_PROXY=loopback
Please see https://expressjs.com/en/api.html#trust.proxy.options.table and https://expressjs.com/guide/behind-proxies.html.
Your trusted proxy must specified as comma-separated on WEB_TRUST_PROXY.
Cloudflare IPs are trusted automatically by this app. No need to specify those on WEB_TRUST_PROXY.
But if you use other reverse proxy (we recommend caddy for easy config), don't forget to specify these IP on your reverse proxy.
This is an example to trust Cloudflare IPs on caddy:
{
servers {
trusted_proxies static 173.245.48.0/20 103.21.244.0/22 103.22.200.0/22 103.31.4.0/22 141.101.64.0/18 108.162.192.0/18 190.93.240.0/20 188.114.96.0/20 197.234.240.0/22 198.41.128.0/17 162.158.0.0/15 104.16.0.0/13 104.24.0.0/14 172.64.0.0/13 131.0.72.0/22 2400:cb00::/32 2606:4700::/32 2803:f800::/32 2405:b500::/32 2405:8100::/32 2a06:98c0::/29 2c0f:f248::/32
}
}
Or you can use 'WEB_USE_CF_CONNECTING_IP=yes" to force use cf-connecting-ip from header as request ip, but we don't recommend it and there is plan to remove WEB_USE_CF_CONNECTING_IP method from our code in the future.
Please post issue or discussion on github.
This software licensed under MIT License. Feel free to use it.
See CHANGELOG.md file.
You can use this software freely. You can also modified it freely. Free as a beer and free as a speech. But of course we love donation. But remember, donation is not a must.
It will just makes us happier to keep develop and maintain this application.
You can donate this project by sending to these cryptocurrency addresses (thanks for qrcodemonkey for generating QRs):
47kucingmMofTNakN2uhH4YG3m9fwK4bGQNEnRANf26Ei4DATqWj1B2bADCtZdYQmEREcz4yVWEkMgMQdffLNsu8Fh4rhkc
nano_3kucingsf315nsym3whdtea86hy7ighetdyseuczue9p8j15pm8bx99beafa
You can also donate your domain name to us, so we can serve your domain in our redirector service. Please post on github's issue or discussion.