Skip to the content.

Installation Guide

← Back to Home

For modern Debian-based systems (Ubuntu 20.04+, Debian 11+):

wget -O - https://raw.githubusercontent.com/theta42/proxy/master/ops/install.sh | sudo bash

This automated installer will:

Manual Installation

System Requirements

Step 1: Install Dependencies

Ubuntu/Debian:

apt install libpam0g-dev build-essential redis-server luarocks -y

Step 2: Install Node.js 20.x

curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | \
  sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg

NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | \
  sudo tee /etc/apt/sources.list.d/nodesource.list

apt update && apt install nodejs -y

Verify installation:

node --version  # Should show v20.x.x
npm --version

Step 3: Install OpenResty

wget -O - https://openresty.org/package/pubkey.gpg | \
  sudo gpg --dearmor -o /usr/share/keyrings/openresty.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty.gpg] http://openresty.org/package/ubuntu $(lsb_release -sc) main" | \
  sudo tee /etc/apt/sources.list.d/openresty.list

apt update && apt install openresty -y

Step 4: Install Lua Dependencies

luarocks install lua-resty-auto-ssl
luarocks install luasocket

Step 5: SSL Configuration

Create fallback SSL certificates:

mkdir -p /etc/ssl/

openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \
  -subj '/CN=sni-support-required-for-valid-ssl' \
  -keyout /etc/ssl/resty-auto-ssl-fallback.key \
  -out /etc/ssl/resty-auto-ssl-fallback.crt

Step 6: Configure OpenResty

Clone the repository and copy configuration files:

cd /var/www
git clone https://github.com/theta42/proxy.git
cd proxy

# Copy nginx configs
mkdir -p /etc/openresty/sites-enabled/
cp ops/nginx_conf/nginx.conf /etc/openresty/nginx.conf
cp ops/nginx_conf/autossl.conf /etc/openresty/autossl.conf
cp ops/nginx_conf/proxy.conf /etc/openresty/sites-enabled/000-proxy
cp ops/nginx_conf/targetinfo.lua /usr/local/openresty/lualib/targetinfo.lua

Step 7: Install Application

cd /var/www/proxy/nodejs
npm install

Step 8: Configure Systemd Service

cp /var/www/proxy/ops/proxy.service /etc/systemd/system/proxy.service
systemctl daemon-reload
systemctl enable proxy.service
systemctl start proxy.service

Verify service is running:

systemctl status proxy.service

Step 9: Initial Setup

The proxy API will be available on port 3000 by default. You’ll need to:

  1. Create your first user account
  2. Configure DNS providers (for wildcard SSL)
  3. Add your first host

See the API Reference for details.

Configuration

Environment Variables

Redis Configuration

The proxy uses Redis with the prefix proxy_. To change this, edit nodejs/conf/base.js:

redis: {
  prefix: 'proxy_'
}

OpenResty Configuration

Key configuration files in /etc/openresty/:

Unix Socket

The proxy communicates with OpenResty via Unix socket at:

/var/run/proxy_lookup.socket

This path is configurable in nodejs/conf/base.js.

Troubleshooting

Service won’t start

Check logs:

journalctl -u proxy.service -f

Common issues:

SSL certificates not working

Check OpenResty logs:

tail -f /var/log/nginx/error.log

Common issues:

Host lookup not working

Check Unix socket:

ls -la /var/run/proxy_lookup.socket
# Should show srwxrwxrwx (socket permissions)

Test lookup:

echo '{"domain":"example.com"}' | nc -U /var/run/proxy_lookup.socket

Next Steps

← Back to Home