- Command line
$ caddy reverse-proxy --from :2080 --to :9000
$ curl -v 127.0.0.1:2080
- Using Caddyfile, is the same as
caddy reverse-proxy --from :2080 --to :9000
:2080
reverse_proxy :9000
This is the Caddyfile for h2jammy.yushei.ne
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
h2jammy.yushei.net {
# ssl certificate from cerbot
# tls /etc/letsencrypt/live/h2jammy.yushei.net/fullchain.pem /etc/letsencrypt/live/h2jammy.yushei.net/privkey.pem
tls /etc/caddy/fullchain.pem /etc/caddy/privkey.pem
# Set this path to your site's directory.
root * /usr/share/caddy
# Enable the static file server.
file_server
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}
http://h2jammy.yushei.net:43889 {
# ssl certificate from cerbot
# tls /etc/letsencrypt/live/h2jammy.yushei.net/fullchain.pem /etc/letsencrypt/live/h2jammy.yushei.net/privkey.pem
# tls /etc/caddy/fullchain.pem /etc/caddy/privkey.pem
log {
output file /var/log/caddy/access.log
}
reverse_proxy / http://orangepi5.yushei.net:43888 {
header_up Host {host}
header_up X-Real-IP {remote}
header_up X-Forwarded-For {remote}
header_up X-Forwarded-Proto {scheme}
}
}
# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile
And this is the Caddyfile for gorangpi5.yushei.net
# https://github.com/dbohdan/caddy-markdown-site
# Copyright (c) 2021 D. Bohdan. License: MIT.
http://orangepi5.yushei.net:43888 {
log {
output file /var/log/caddy/access.log
}
root * demo
# root * /opt/munetakaJupyterHub
# send http for nginx server
# protocols h2c
encode gzip
file_server browse
# browse
templates
@media {
path /favicon.ico
path /media/*
}
@templates {
path /templates/*
not path /templates/*.css /templates/*.js
}
@markdown {
path_regexp \.md$
}
@markdown_exists {
file {path}.md
}
handle @media {
file_server
}
handle @templates {
error 403
}
handle @markdown {
rewrite * /templates/index.html
}
handle @markdown_exists {
map {path} {caddy_markdown_site.append_to_path} {
default extension
}
rewrite * /templates/index.html
}
handle_errors {
file_server
templates
@markdown_index_exists_404 {
file {path}/index.md
expression `{http.error.status_code} == 404`
}
handle @markdown_index_exists_404 {
map {path} {caddy_markdown_site.append_to_path} {
default index
}
file_server {
status 200
}
rewrite * /templates/index.html
}
handle {
rewrite * /templates/error.html
}
# reverse_proxy http://h2jammy.yushei.net:43999
}
Both running caddy server. Wht http://h2jammy.yushei.net:43889 retriev nothing?