Skip to content

Instantly share code, notes, and snippets.

@julianxhokaxhiu
Last active May 13, 2023 22:39
Show Gist options
  • Save julianxhokaxhiu/1488427cfb02e39e24f4e8fddb32c7f3 to your computer and use it in GitHub Desktop.
Save julianxhokaxhiu/1488427cfb02e39e24f4e8fddb32c7f3 to your computer and use it in GitHub Desktop.
Quickly publish online a localhost tunnel using tunnel.pyjam.as and a Makefile

How to use

By default the Makefile will use the HTTP port 8080

  1. Make sure you have Wireguard installed ( wg-quick )
  2. Save the Makefile somewhere in your own project
  3. Run make to know available goals

Run the Makefile

# Run on the default HTTP 8080 port
make up

# Run on a custom HTTP port
make up HTTP_PORT=8000

# Close the tunnel
make down
###############################################################################
# ENVIRONMENT CONFIGURATION
###############################################################################
MAKEFLAGS += --no-print-directory
SHELL=/bin/bash
# Use default as default goal when running 'make'
.PHONY: default
.DEFAULT_GOAL := default
###############################################################################
# GOAL PARAMETERS
###############################################################################
# HTTP port
HTTP_PORT ?= "8080"
###############################################################################
# GOALS ( safe defaults )
###############################################################################
default:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
up: ## Start the tunnel on 8080 ( customize the port using 'make up HTTP_PORT=8000' for eg. )
@curl --silent -o tunnel.conf https://tunnel.pyjam.as/$(HTTP_PORT) && wg-quick up ./tunnel.conf
down: ## Stop the tunnel
@wg-quick down ./tunnel.conf
@rm ./tunnel.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment