1. Caddy version (caddy version
):
caddy version
v2.4.3 h1:Y1FaV2N4WO3rBqxSYA8UZsZTQdN+PwcoOcAiZTM8C0I=
2. How I run Caddy:
caddy:
restart: always
image: caddy:2.4.3-alpine
volumes:
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
- ./caddy/data:/data
- ./caddy/certificate.pem:/etc/ssl/certs/certificate.pem
- ./caddy/key.pem:/etc/ssl/private/key.pem
ports:
- 80:80
- 443:443
a. System environment:
docker -v
Docker version 20.10.7, build f0df350
docker-compose -v
docker-compose version 1.29.2, build 5becea4c
b. Command:
docker-compose up
c. Service/unit/compose file:
Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.
d. My complete Caddyfile or JSON config:
:80 {
reverse_proxy http://test.tld
}
3. The problem I’m having:
Internet => server:80 => caddy => network => test.tld
(GitHub - lucaslorentz/caddy-docker-proxy: Caddy as a reverse proxy for Docker )
I have a server on the internet exposing 80 and 443
The server is running the docker-compose containing a caddy service.
I am running test.tld
on the same network where the server can reach to
Here is the curl log from the server
curl -I http://test.tld
HTTP/1.1 200 OK
Content-Length: 6732
Content-Type: text/html; charset=utf-8
Date: Fri, 18 Mar 2022 22:27:40 GMT
Etag: "1a4c-Hw+mSj4DXKG3tnL9Oj87rYJSiH0"
Server: Caddy
Vary: Accept-Encoding
X-Powered-By: Next.js
It seems test.tld
(served by GitHub - lucaslorentz/caddy-docker-proxy: Caddy as a reverse proxy for Docker ) can access by HTTP
, but when I access from the internet side, it redirects to HTTPS
When I compared config json file, test.tld
side has
"automatic_https": { "skip": ["test.tld"] }
but the server side caddy do not have this.
How can I set the above config through just Caddyfile
?
4. Error messages and/or full log output:
5. What I already tried:
opened 05:18AM - 03 Apr 20 UTC
closed 10:59PM - 19 May 20 UTC
feature
Is it possible to [disable the HTTP-to-HTTPS redirects](https://caddyserver.com/… docs/json/apps/http/servers/automatic_https/disable_redirects/) in Caddyfile?
My Caddyfile is:
```
sourcegraph.test:3443
tls internal
reverse_proxy localhost:3080
```
When I run `caddy` (as a non-root user), I get an error because it can't bind to port 80:
```
$ caddy run --config=dev/Caddyfile
2020/04/03 05:14:29.418 INFO using provided configuration {"config_file": "dev/Caddyfile", "config_adapter": ""}
2020/04/03 05:14:29.419 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["localhost:2019"]}
2020/04/02 22:14:29 [INFO][cache:0xc0009afc20] Started certificate maintenance routine
2020/04/03 05:14:29.427 INFO http enabling automatic HTTP->HTTPS redirects {"server_name": "srv0"}
2020/04/03 05:14:29.468 INFO pki.ca.local root certificate is already trusted by system {"path": "storage:pki/authorities/local/root.crt"}
2020/04/03 05:14:29.468 INFO tls cleaned up storage units
run: loading initial config: loading new config: http app module: start: tcp: listening on :80: listen tcp :80: bind: permission denied
```
I don't want it to try to bind to port 80. I believe it's doing so to enable HTTP-to-HTTPS redirects, so disabling those would suffice to solve my problem.
I can see how to disable them in JSON, but I like using Caddyfile because it's simple. I would like to not have to switch everything to JSON just for this one directive.
(Ref: https://github.com/sourcegraph/sourcegraph/issues/9536)
6. Links to relevant resources:
This was what I was trying to do. Tailscale part aside, I was just trying to reverse_proxy from a caddy to another caddy like that.
I then figured that I didn’t have to use caddy on the end IF I used network_mode: host
and specify a port to connect.
# or just use ports ...
# network_mode: host
ports:
- 8080:3000
Caddyfile
domain.name {
reverse_proxy http://test.tld:8080
}
system
(system)
Closed
April 17, 2022, 10:44pm
4
This topic was automatically closed after 30 days. New replies are no longer allowed.