generated from ddev/ddev-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Migrate Tailscale configuration to YAML and update proxy settings #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
atj4me
wants to merge
41
commits into
main
Choose a base branch
from
atj4me/issue19
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 22 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
159baf9
feat: migrate tailscale configuration to YAML and update proxy settings
atj4me 9935792
fix: update project_files to reference correct configuration file
atj4me 97fa037
fix: update web_extra_exposed_ports to use string format
atj4me 4fe2ef6
fix: remove unused web_extra_volumes configuration
atj4me fd30bff
fix: remove web_extra_exposed_ports configuration
atj4me 876ea00
feat: add Dockerfile for Tailscale installation and update project files
atj4me b6e41c4
fix: update project_files to reference correct Dockerfile path and ad…
atj4me a936675
feat: update install.yaml to reference Dockerfile.tailscale and add D…
atj4me d6f5403
feat: simplify Tailscale command in config and add environment variab…
atj4me 58eca19
fix: add missing comments to Dockerfile.tailscale for clarity
atj4me 7b7864a
fix: add missing newline for clarity in config.tailscale.yaml
atj4me 5c26b7e
fix: improve clarity in config.tailscale.yaml by adding comments and …
atj4me b69781d
fix: correct paths in config.tailscale.yaml and add docker-compose.ta…
atj4me 13e2176
feat: add Tailscale configuration and Dockerfile for routing capabili…
atj4me e917db2
fix: update project file reference from config.tailscale.yaml to conf…
atj4me dca717e
feat: enhance Tailscale routing setup with improved configuration and…
atj4me 53886d9
feat: add 'share' command to Tailscale functionality and remove obsol…
atj4me dc46227
fix: remove obsolete Tailscale configuration files from install.yaml
atj4me 96931a4
chore: update configuration for Tailscale routing capabilities
atj4me 000a123
feat: add support for sharing with public flag and forward arbitrary …
atj4me ecb3771
feat: update Tailscale share command documentation and remove obsolet…
atj4me bbcb5a3
fix: update ownership command in Dockerfile to use dynamic username v…
atj4me 5e03fe1
Update config.tailscale-router.yaml
atj4me 78e8aa4
Update config.tailscale-router.yaml
atj4me 34ce943
Update commands/host/tailscale
atj4me 666e005
Update config.tailscale-router.yaml
atj4me 2bce8a3
Update commands/host/tailscale
atj4me 9ef1771
Refactor Tailscale command and update configuration for hostname
atj4me acee5df
Update commands/host/tailscale
atj4me 68f090c
Apply suggestion from @Copilot
atj4me 4638319
Apply suggestion from @Copilot
atj4me b78154c
Apply suggestion from @Copilot
atj4me 0cb927e
Update Tailscale configuration and Dockerfile for improved setup
atj4me f3fbc9a
Merge branch 'atj4me/issue19' of https://github.com/atj4me/ddev-tails…
atj4me cd82437
Fix docker-compose file reference in install.yaml
atj4me 92b3b38
Add traefik configuration file to project files in install.yaml
atj4me e02732c
Add ddev-generated comments to Traefik configuration files
atj4me 7692914
Fix typo in install.yaml: change 'global_config' to 'global_files'
atj4me 50d9d28
Update install.yaml for improved installation instructions
atj4me eb1c853
Fix file paths in project_files section of install.yaml
atj4me 7a36f58
Add README.txt for custom certificates and update project_files in in…
atj4me File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,84 @@ | ||
#!/usr/bin/env bash | ||
|
||
## #ddev-generated: If you want to edit and own this file, remove this line. | ||
## Description: Tailscale command with launch functionality | ||
## Usage: tailscale [launch|stat|proxy|url|args...] | ||
## Example: "ddev tailscale launch" | ||
## Description: Tailscale command with launch/share functionality | ||
## Usage: tailscale [launch|share|stat|proxy|url|args...] | ||
## Example: "ddev tailscale launch" or "ddev tailscale share" | ||
|
||
if [ "$1" = "launch" ] || [ $# -eq 0 ]; then | ||
TAILSCALE_URL=$(ddev exec -s tailscale-router tailscale funnel status | grep -o 'https://[^[:space:]]*' | head -1) | ||
|
||
|
||
# Helper to run tailscale in the web container | ||
tailscale_web() { | ||
ddev exec -s web tailscale "$@" | ||
} | ||
|
||
# Helper to extract the Tailscale URL from status | ||
get_tailscale_url() { | ||
tailscale_web "$1" status | grep -o 'https://[^[:space:]]*' | head -1 | ||
} | ||
|
||
# Helper to run tailscale share/funnel/serve with options | ||
run_tailscale_share() { | ||
local cmd="$1" | ||
local bg_flag="$2" | ||
tailscale_web $cmd $bg_flag 127.0.0.1:$DDEV_ROUTER_HTTP_PORT | ||
atj4me marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
stop_tailscale_share() { | ||
local cmd="$1" | ||
tailscale_web $cmd --https=443 off | ||
atj4me marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
# Parse args, handle --public, and forward all other args | ||
CMD="serve" | ||
LABEL="private" | ||
ARGS=() | ||
for arg in "$@"; do | ||
if [ "$arg" = "--public" ]; then | ||
CMD="funnel" | ||
LABEL="public" | ||
else | ||
ARGS+=("$arg") | ||
fi | ||
done | ||
|
||
# If no args, default to launching a share | ||
if [ ${#ARGS[@]} -eq 0 ] || [ "${ARGS[0]}" = "launch" ]; then | ||
TAILSCALE_URL=$(get_tailscale_url $CMD) | ||
if [ -z "$TAILSCALE_URL" ]; then | ||
echo "No share found, creating one..." | ||
run_tailscale_share "$CMD" "--bg" | ||
atj4me marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sleep 2 | ||
TAILSCALE_URL=$(get_tailscale_url $CMD) | ||
fi | ||
if [ -z "$TAILSCALE_URL" ]; then | ||
echo "Error: Could not retrieve Tailscale URL after $CMD." | ||
exit 1 | ||
fi | ||
echo "Tailscale $LABEL URL: $TAILSCALE_URL" | ||
ddev launch "$TAILSCALE_URL" | ||
elif [ "${ARGS[0]}" = "share" ]; then | ||
BG_FLAG="" | ||
for arg in "${ARGS[@]}"; do | ||
if [ "$arg" = "--bg" ]; then | ||
BG_FLAG="--bg" | ||
fi | ||
done | ||
run_tailscale_share "$CMD" "$BG_FLAG" | ||
TAILSCALE_URL=$(get_tailscale_url $CMD) | ||
if [ -z "$TAILSCALE_URL" ]; then | ||
echo "Error: Could not retrieve Tailscale URL." | ||
echo "Error: Could not retrieve Tailscale URL after $CMD." | ||
exit 1 | ||
fi | ||
|
||
echo "Tailscale $LABEL URL: $TAILSCALE_URL" | ||
ddev launch "$TAILSCALE_URL" | ||
elif [ "$1" = "stat" ]; then | ||
ddev exec -s tailscale-router tailscale status --self --peers=false --active=true | ||
elif [ "$1" = "proxy" ]; then | ||
ddev exec -s tailscale-router tailscale funnel status | ||
elif [ "$1" = "url" ]; then | ||
ddev exec -s tailscale-router tailscale funnel status | grep -o 'https://[^[:space:]]*' | head -1 | ||
elif [ "${ARGS[0]}" = "stop" ] ; then | ||
stop_tailscale_share "${ARGS[0]}" | ||
atj4me marked this conversation as resolved.
Show resolved
Hide resolved
|
||
elif [ "${ARGS[0]}" = "stat" ]; then | ||
tailscale_web status --self --peers=false --active=true | ||
elif [ "${ARGS[0]}" = "proxy" ]; then | ||
tailscale_web $CMD status | ||
elif [ "${ARGS[0]}" = "url" ]; then | ||
get_tailscale_url $CMD | ||
else | ||
ddev exec -s tailscale-router tailscale "$@" | ||
tailscale_web "${ARGS[@]}" | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ddev-generated | ||
# This configuration adds Tailscale routing capabilities to the web container. | ||
web_extra_daemons: | ||
- name: tailscale-service | ||
command: tailscaled --statedir=${TS_STATE_DIR} --tun=userspace-networking | ||
atj4me marked this conversation as resolved.
Show resolved
Hide resolved
|
||
directory: /usr/sbin | ||
- name: "tailscale-router" | ||
command: tailscale up --auth-key=$TS_AUTHKEY --hostname=$TS_HOSTNAME $TS_EXTRA_ARGS | ||
atj4me marked this conversation as resolved.
Show resolved
Hide resolved
|
||
directory: /var/www/html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,37 +1,15 @@ | ||||||
#ddev-generated | ||||||
services: | ||||||
tailscale-router: | ||||||
image: ${TS_DOCKER_IMAGE:-tailscale/tailscale:latest}-${DDEV_SITENAME}-built | ||||||
build: | ||||||
dockerfile_inline: | | ||||||
ARG TS_DOCKER_IMAGE=scratch | ||||||
FROM $$TS_DOCKER_IMAGE | ||||||
RUN apk add --no-cache socat | ||||||
args: | ||||||
TS_DOCKER_IMAGE: ${TS_DOCKER_IMAGE:-tailscale/tailscale:latest} | ||||||
hostname: ${DDEV_SITENAME} | ||||||
container_name: ddev-${DDEV_SITENAME}-tailscale-router | ||||||
web: | ||||||
environment: | ||||||
TS_AUTHKEY: ${TS_AUTHKEY:-} | ||||||
TS_HOSTNAME: ${DDEV_SITENAME} | ||||||
TS_EXTRA_ARGS: --accept-routes --ssh | ||||||
TS_STATE_DIR: /var/lib/tailscale | ||||||
TS_USERSPACE: "true" | ||||||
TS_PRIVACY: ${TS_PRIVACY:-private} | ||||||
TS_SERVE_CONFIG: /config/tailscale-${TS_PRIVACY:-private}.json | ||||||
- TS_AUTHKEY=${TS_AUTHKEY} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- TS_HOSTNAME=${DDEV_SITENAME} | ||||||
- TS_EXTRA_ARGS=--accept-routes --ssh | ||||||
- TS_STATE_DIR=/var/lib/tailscale | ||||||
- TS_USERSPACE=false | ||||||
- TS_PRIVACY=${TS_PRIVACY:-private} | ||||||
- TS_SERVE_CONFIG=/config/tailscale-${TS_PRIVACY}.json | ||||||
volumes: | ||||||
- tailscale-router-state:/var/lib/tailscale | ||||||
- ./tailscale-router/config:/config:ro | ||||||
- .:/mnt/ddev_config | ||||||
- ddev-global-cache:/mnt/ddev-global-cache | ||||||
restart: "no" | ||||||
labels: | ||||||
com.ddev.site-name: ${DDEV_SITENAME} | ||||||
com.ddev.approot: ${DDEV_APPROOT} | ||||||
depends_on: | ||||||
- web | ||||||
post_start: | ||||||
- command: ["sh", "-c", "socat TCP-LISTEN:8080,reuseaddr,fork TCP:web:${DDEV_ROUTER_HTTP_PORT} >> /var/log/ddev.log 2>&1 &"] | ||||||
|
||||||
- tailscale-router-state:/var/lib/tailscale | ||||||
volumes: | ||||||
tailscale-router-state: | ||||||
atj4me marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.