Reverse Proxy API powered by Nginx.
apt-get update && apt-get upgrade -y
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
apt-get install -y nodejs unzip certbot nginx
mkdir -p /etc/reverseproxy
cd /etc/reverseproxy
curl -Lo proxy.zip https://github.com/j122j/reverseproxy/releases/latest/download/proxy.zip
unzip -o proxy.zip
npm install
cp example.env .env
# Edit .env
cp reverseproxy.service /etc/systemd/system/reverseproxy.service
systemctl enable --now reverseproxy
mkdir -p /etc/nginx/streams
cat >> /etc/nginx/nginx.conf << EOF
stream {
include /etc/nginx/streams/*;
}
EOF
nginx -t && systemctl restart nginx
cd /etc/reverseproxy
curl -Lo proxy.zip https://github.com/j122j/reverseproxy/releases/latest/download/proxy.zip
unzip -o proxy.zip
npm install
cp reverseproxy.service /etc/systemd/system/reverseproxy.service
systemctl daemon-reload
systemctl restart reverseproxy
cd /etc/reverseproxy
node dist/migrate/addMetadata.js
Authentication is performed with the Authorization
HTTP header in the format Authorization: AUTHORIZATION
Get the API version.
Responses
{
"version": "1.2.0",
"statusCode": 200
}
Get all proxies.
Responses
[
{
"version": "v1.0",
"domain": "example.com",
"target": "http://target.com:8080",
"ssl": true,
"letsencryptDir": "/var/www/html"
},
{
"version": "v1.0",
"domain": "example.org",
"target": "http://target.com:8181",
"ssl": false
}
]
Create a proxy with a domain and a target.
If ssl is set to true
, a SSL Certificate will be created using Certbot.
Body
{
"domain": "example.com",
"target": "http://target.com:8080",
"ssl": true
}
Responses
{
"message": "Proxy created",
"statusCode": 200
}
{
"error": "Invalid request",
"statusCode": 400
}
{
"error": "Invalid target",
"statusCode": 400
}
{
"error": "Could not create SSL certificate",
"statusCode": 500
}
{
"error": "Could not create proxy",
"statusCode": 500
}
Delete the proxy with the domain.
Add ?keepCertificate=true
to not delete the SSL certificate.
Responses
{
"message": "Proxy deleted",
"statusCode": 200
}
{
"error": "Could not delete proxy",
"statusCode": 500
}
Get all streams.
Responses
[
{
"version": "v1.0",
"name": "example-stream",
"listen": "8080",
"target": "target.com:8080"
},
{
"version": "v1.0",
"name": "example-stream-too",
"listen": "127.0.0.1:8080 udp",
"target": "target.com:8181"
}
]
Create a stream with a name, domain, and target.
You can add udp after listen port (Example: 127.0.0.1:8080 udp
).
Body
{
"name": "example-stream",
"listen": "127.0.0.1:8080",
"target": "target.com:8080"
}
Responses
{
"message": "Stream created",
"statusCode": 200
}
{
"error": "Invalid request",
"statusCode": 400
}
{
"error": "Invalid name",
"statusCode": 400
}
{
"error": "Invalid listen",
"statusCode": 400
}
{
"error": "Could not create stream",
"statusCode": 500
}
Delete the stream with the name.
Responses
{
"message": "Stream deleted",
"statusCode": 200
}
{
"error": "Could not delete stream",
"statusCode": 500
}
{
"error": "METHOD /PATH not found",
"statusCode": 404
}
{
"error": "Error Message",
"stack": "Error Stack",
"statusCode": 500
}