Expose your service/homelab/On-premise Hosting using boringproxy

Expose your service to the world using boringproxy

What is boringproxy?

Boringproxy is a reverse proxy that allows you to expose your local development environment to the internet. It’s free for personal use and it’s easy to use.

How to use it?

Prerequisites

  • Server with public IP address
  • Domain name
  • Local apps that you want to expose to the world

Installation

# Install boringproxy
curl -LO https://github.com/boringproxy/boringproxy/releases/latest/download/boringproxy-linux-x86_64

# Make it executable
chmod +x boringproxy-linux-x86_64

# Move it to /usr/local/bin
sudo mv boringproxy-linux-x86_64 /usr/local/bin/boringproxy

# Allow binding to ports 80 and 443
sudo setcap cap_net_bind_service=+ep /usr/local/bin/boringproxy

Setup Domain

On your domain registrar, add the following A records:

  • @ pointing to your server’s public IP address
  • * pointing to your server’s public IP address

Run boringproxy in the background using tmux

tmux new -s boringproxy

On tmux, run the following command:

boringproxy server -admin-domain <your-domain> -acme-email <your-email> -accept-ca-terms

Setup your local machine side

Install boring proxy like above

On your local machine, run the following command:

boringproxy client \
-server <your-domain> -token <your-token> \
-user <default is "admin"> -acme-email <your-email> \
-client-name <your-client-name>

Access boringproxy dashboard

On your boringproxy server side, run the following command:

cat ~/boringproxy_db.json

Output should be like this:

    {                                                           
    "admin_domain": "<your-domain>",                       
    "tokens": {                                       
        "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx": {   
        "owner": "admin"                        
        }
    ...

Access your boringproxy dashboard using this URL: https://<your-domain> and paste the token on the login page.

Test exposing your service

On your local machine, run the following command:

# install nginx
sudo apt-get install nginx

# start nginx
sudo systemctl start nginx

On your boringproxy dashboard, add tunnel and set like this:

  • Domain: <your-choose-domain>
  • Tunnel Port: Random
  • Client Name: <choose-your-client-name>
  • Client Address: 127.0.0.1
  • Client Port: 80
  • TLS Termination: <client-https>
  • and submit

On your browser, access your service using this URL: https://<your-choose-domain> and walla, your service has been exposed to the world

References