[新服务] cloudflared tunnel docker & native
date
Mar 1, 2024
slug
newservice-cloudflared-tunnel
status
Published
summary
新服务-
tags
service
type
Post
URL
Summary步骤#native docker-composer.yamlhttps只支持一级subdomain,比如xxx.domain.com, 而不是xxx.yyy.domain.com - otherwise ssl error参考(带额外认证)
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F79e99652-d5b9-4f77-b4a7-df11d59c6483%2F848937c1-689e-4fc9-89d9-ce971ee7497c%2FUntitled.jpeg?table=block&id=101e9ccf-761b-45f5-bac3-f9bf5c7965e5&cache=v2)
Summary
步骤
#native
brew install cloudflared &&
sudo cloudflared service install eyJhIjoiOxxxxxx
sudo cloudflared service --help
Password:
NAME:
cloudflared service - Manages the cloudflared launch agent
USAGE:
cloudflared service command [command options] [arguments...]
COMMANDS:
install Install cloudflared as an user launch agent
uninstall Uninstall the cloudflared launch agent
help, h Shows a list of commands or help for one command
OPTIONS:
--help, -h show help (default: false)
# logs
/Library/Logs/com.cloudflare.cloudflared.err.log
/Library/Logs/com.cloudflare.cloudflared.out.log
docker-composer.yaml
cd ~/tmp_qh/data/
mkdir $(hostname)-cloudflared && cd $(hostname)-cloudflared
cat > docker-compose.yml <<EOF
version: '3.8'
services:
cloudflared:
image: cloudflare/cloudflared:latest
command: tunnel --no-autoupdate run --token eyJhIjoixxx
# Optional configurations
container_name: cloudflared_tunnel
# To expose ports, if necessary, uncomment the following line and adjust as needed
# ports:
# - "your_host_port:your_container_port" restart: unless-stopped
# If your service needs specific network settings, you can specify them here
# networks:
# - cloudflared_tunnel-network
# - npm_nginx_proxy_manager-network
#networks:
# "docker network create " first if not done
# cloudflared_tunnel-network:
# external: true
# npm_nginx_proxy_manager-network:
# external: true
# or just use one network
networks:
default:
name: npm_nginx_proxy_manager-network
external: true
EOF
# in server can use host.docker.internal to access host_ip:port
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F79e99652-d5b9-4f77-b4a7-df11d59c6483%2Fc6ceb9ea-4f2d-4f6c-9c31-c4dd30000210%2FUntitled.jpeg?table=block&id=ba1a3165-b9d1-44f8-afab-d0128b91b03f&cache=v2)
https只支持一级subdomain,比如xxx.domain.com, 而不是xxx.yyy.domain.com - otherwise ssl error
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F79e99652-d5b9-4f77-b4a7-df11d59c6483%2F7b5241f2-a96e-4c61-8e6b-f88afee30e11%2FUntitled.jpeg?table=block&id=b7809e74-7671-45cb-acdf-c63f751d9ec5&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F79e99652-d5b9-4f77-b4a7-df11d59c6483%2Ffa06ce19-0612-46b5-9ad1-ead93865d1dc%2FUntitled.jpeg?table=block&id=e16aa0db-d762-42c5-bf57-7222425f2c17&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F79e99652-d5b9-4f77-b4a7-df11d59c6483%2F0f9099e0-33a0-4fc5-9b19-d00594923e34%2FUntitled.jpeg?table=block&id=d924fd08-8adf-48ca-9070-23f6e0f2f429&cache=v2)
参考(带额外认证)
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F79e99652-d5b9-4f77-b4a7-df11d59c6483%2F9ddd4b13-a20b-43c3-8e6f-f9513e767940%2FUntitled.jpeg?table=block&id=22e348f6-23d8-4e20-ab0a-fe90308877d9&cache=v2)