Self-hosting. Caddy

ΠŸΡ€ΠΎΡΡ‚ΠΎ http сСрвСр для ΠΏΡƒΠ±Π»ΠΈΠΊΠ°Ρ†ΠΈΠΈ сайтов ΠΈ ΠΎΡ€Π³Π°Π½ΠΈΠ·Π°Ρ†ΠΈΠΈ рСвСрс прокси. Для настройки ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ΡΡ Ρ„Π°ΠΉΠ» ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΈ Caddyfile с json описаниСм сайтов. Π˜ΠΌΠ΅Π΅Ρ‚ большоС количСство ΠΌΠΎΠ΄ΡƒΠ»Π΅ΠΉ ΠΈ Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠΉ, ΠΌΠΎΠΆΠ΅Ρ‚ Π³ΠΈΠ±ΠΊΠΎ Π½Π°ΡΡ‚Ρ€Π°ΠΈΠ²Π°Ρ‚ΡŒΡΡ.

НС ΠΈΠΌΠ΅Π΅Ρ‚ графичСского интСрфСйса, вся настройка Ρ‡Π΅Ρ€Π΅Π· Ρ„Π°ΠΉΠ» ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΈ. ΠŸΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΈΠ²Π°Π΅Ρ‚ dns chelenge.

ΠžΡ„ΠΈΡ†ΠΈΠ°Π»ΡŒΠ½Ρ‹ΠΉ сайт: Caddy - The Ultimate Server with Automatic HTTPS
ΠŸΡ€ΠΎΠ΅ΠΊΡ‚ Π½Π° GitHub GitHub - caddyserver/caddy: Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

ΠŸΡ€ΠΈΠΌΠ΅Ρ€ docker compose Ρ„Π°ΠΉΠ»Π°:

Π”ΠΎΠΊΠ΅Ρ€ Ρ„Π°ΠΉΠ» для запуска

services:
  caddy:
    image: ghcr.io/deniom3/caddy-cloudflare-transform:latest
    container_name: caddy
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    ports:
      - 80:80
      - 443:443 
    environment:
      ACME_AGREE: true
      CLOUDFLARE_API_TOKEN: <CLOUDFLARE_API_TOKEN>
      CLOUDFLARE_EMAIL: <CLOUDFLARE_EMAIL>
      DOMAIN: deniom.ru
    volumes:
      - ./data:/data
      - ./config:/config
      - ./logs:/logs
      - ./Caddyfile:/etc/caddy/Caddyfile  

ΠŸΡ€ΠΈΠΌΠ΅Ρ€ ΠΊΠΎΠ½Ρ„ΠΈΠ³ Ρ„Π°ΠΉΠ»Π°

ΠŸΡ€ΠΈΠΌΠ΅Ρ€ настроСк Caddy для использования ΠΊΠ°ΠΊ рСвСрс прокси Π² домашнСй сСти. ΠŸΠΎΠ΄Ρ€ΠΎΠ±Π½Π°Ρ настройка рассмотрСна Π² Настройка рСвСрс прокси Caddy ΠΈ Fail2Ban Π² docker.

(common) {
	header /* {
	-Server
	}
}

(cloudflare) {
	import common
	tls { 
		dns cloudflare {env.CLOUDFLARE_API_TOKEN}
	}
}

(local) {
	@allowed remote_ip 192.168.0.0/24
	handle {
		respond 401
	}
}

{
	log access-log {
		include http.log.access
		output file /logs/access.log {
		  roll_keep_for 48h
		}
		format transform `{ts} {request>headers>X-Forwarded-For>[0]:request>remote_ip} {request>host} {request>method} {request>uri} {status}` {
			time_format "02/Jan/2006:15:04:05"
		}
	}
}

home-assistant.{env.DOMAIN} {
	import cloudflare
	
	log
	
	reverse_proxy 192.168.0.125:8123
}

vaultwarden.{env.DOMAIN} {
	import cloudflare
	
	log
	
	reverse_proxy 192.168.0.132:10380 {
		header_up X-Real-IP {remote_host}
	}
}

nextcloud.{env.DOMAIN} {
	import cloudflare
	
	log
	
	reverse_proxy 192.168.0.133:11000
}

immich.{env.DOMAIN} {
	import cloudflare
	
	log
	
	reverse_proxy 192.168.0.136:2283
}

jackett.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.134:9117
	}
}

plex.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.134:32400
	}
}

portainer.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.132:9000
	}
}

adguard.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.1:8080
	}
}

perenio.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.115:80
	}
}

homed.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.115:8080
	}
}

sonarr.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.134:8989
	}
}

radarr.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.134:7878
	}
}

qbittorrent.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.134:8080
	}
}

casaos.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.132:8080
	}
}

calibre.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.132:8083
	}
}

readeck.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.132:8082
	}
}

gitea.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.132:3002
	}
}

grafana.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.135:3000
	}
}

influxdb.{env.DOMAIN} {
	import local
	import cloudflare
	
	log
	
	handle @allowed {
		reverse_proxy 192.168.0.135:8086
	}
}