Unable to get Caddy and Apache2 Servers to work together. They work separately and I have tried numerous suggestions and would be very grateful for a solution.
Meanwhile to simplify switching, restarting, checking status, etc I created a PHP menu system with access the following setup:
â—Ź caddy.service - Caddy HTTP/2 web server
Loaded: loaded (/etc/systemd/system/caddy.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-12-12 11:27:15 +07; 15s ago
Docs: https://caddyserver.com/docs
Main PID: 8611 (caddy)
Tasks: 10 (limit: 4915)
Memory: 2.1M
CGroup: /system.slice/caddy.service
└─8611 /usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp
Dec 12 11:27:15 john systemd[1]: Started Caddy HTTP/2 web server.
Dec 12 11:27:15 john caddy[8611]: 2019/12/12 11:27:15 [INFO] Caddy version: v1.0.4
Dec 12 11:27:15 john caddy[8611]: Activating privacy features... done.
Dec 12 11:27:15 john caddy[8611]: 2019/12/12 11:27:15 [INFO][cache:0xc0001c2190] Started certificate maintenance routine
Dec 12 11:27:15 john caddy[8611]: Serving HTTP on port 2015
Dec 12 11:27:15 john caddy[8611]: http://amum.tk:2015
Dec 12 11:27:15 john caddy[8611]: http://apop.tk:2015
Dec 12 11:27:15 john caddy[8611]: 2019/12/12 11:27:15 [INFO] Serving http://amum.tk:2015
Dec 12 11:27:15 john caddy[8611]: 2019/12/12 11:27:15 [INFO] Serving http://apop.tk:2015
Just a quick question, it looks like in Apache your virtual host is defined to listen on port 80, but Caddy is proxying back to localhost port 2015. Is this accurate? Is there something in the middle translating that traffic where it needs to go?
Actually, after looking a bit closer, it looks like Caddy is starting up and listening on port 2015 as well, as you’ve disabled Automatic HTTPS. So I think it’d be proxying to itself…?
What, exactly, is the setup you want to achieve? Client → Caddy → Apache → PHP?
At the moment I am using a Linode VPS with Ubuntu and Apache2 to run over a dozen PHP and MySqli driven sites.
I would like a Caddy server to run alongside so I can experiment with Golang. All I want at the moment is a simple “Hello-world.html” web page. Later, php, etc
Apache2 users ports 80, 443 and another for MySqli.
You need to set your mind on which server you want to use which ports, they can’t use the same port.
If you want caddy to use 80 you will need to change apache’s port to something else. Then you can proxy to it using caddy.
So, assuming you change apache to listen on 8080, then the Caddyfile should be:
# This one will proxy to apache on port 8080.
apup.tk {
tls off
log /var/log/caddy/caddy-apup-tk-access.log
errors /var/log/caddy/caddy-apup-tk-errors.log
proxy / http://127.0.0.1:8080 {
transparent
}
}
# This will just serve amum.tk on port 80.
amum.tk {
root /path/to/root/www
tls off
log /var/log/caddy/caddy-amum-tk-access.log
errors /var/log/caddy/caddy-amum-tk-errors.log
}
The default HTTP port is 80. Trying to run Caddy on default HTTP(S) ports (80 and 443) but have Apache on port 80 is fundamentally impossible. Apache and Caddy cannot share the port. You must decide which one you want to use that port.