I have followed all the instructions but it was impossible to link the new domain to the server because of openpanel fault.
`root@YTA55242770:~# cat /etc/openpanel/caddy/domains/smmoka.com.conf
HTTP block (port 80) - Handles HTTP traffic
http://smmoka.com, http://*.smmoka.com {
logging for HTTP
log {
output file /var/log/caddy/domlogs/smmoka.com/access.log {
roll_size 100MiB
roll_keep 5
roll_keep_for 720h
}
format json
}
route {
redirects
import /etc/openpanel/caddy/redirects.conf
modsecurity
coraza_waf {
load_owasp_crs
directives Include /etc/openpanel/caddy/coraza_rules.conf
Include /etc/openpanel/caddy/coreruleset/crs-setup.conf.example
Include /etc/openpanel/caddy/coreruleset/rules/*.conf
SecRuleEngine Off
SecAuditEngine RelevantOnly
SecRuleRemoveById 007
SecRuleRemoveByTag example
SecAuditLog /var/log/caddy/coraza_waf/smmoka.com.log
SecAuditLogParts ABIJDEFHKZ
SecAuditLogFormat json
}
Handle HTTP traffic (port 80)
reverse_proxy http://127.0.0.1:80 {
header_up Host {host}
}
}
}
HTTPS block (port 443) - Handles HTTPS traffic
https://smmoka.com, https://*.smmoka.com {
logging for HTTPS
log {
output file /var/log/caddy/domlogs/smmoka.com/access.log {
roll_size 100MiB
roll_keep 5
roll_keep_for 720h
}
format json
}
route {
redirects
import /etc/openpanel/caddy/redirects.conf
modsecurity
coraza_waf {
load_owasp_crs
directives Include /etc/openpanel/caddy/coraza_rules.conf
Include /etc/openpanel/caddy/coreruleset/crs-setup.conf.example
Include /etc/openpanel/caddy/coreruleset/rules/*.conf
SecRuleEngine Off
SecAuditEngine RelevantOnly
SecRuleRemoveById 007
SecRuleRemoveByTag example
SecAuditLog /var/log/caddy/coraza_waf/smmoka.com.log
SecAuditLogParts ABIJDEFHKZ
SecAuditLogFormat json
}
Handle HTTPS traffic (port 443)
reverse_proxy https://127.0.0.1:443 {
transport http {
tls_insecure_skip_verify
}
header_up Host {host}
}
# Terminate TLS and pass to Varnish
header_up Host {host}
}
}
SSL (only when SSL certificate is requested)
tls {
on_demand
}
}
root@YTA55242770:~# docker --context smmoka ps --format "table {{.Names}}\t{{.Ports}}"
NAMES PORTS
apache 0.0.0.0:32768->80/tcp, [::]:32768->80/tcp, 0.0.0.0:32769->443/tcp, [::]:32769->443/tcp
php-fpm-8.5 22/tcp, 9000/tcp
-------------------`
The config file has the wrong ports. It's trying to connect to 127.0.0.1:80 and 127.0.0.1:443, but Apache is actually listening on ports 32768 (HTTP) and 32769 (HTTPS). That's exactly why I get 502.
Fixed with these commands:
sed -i 's|reverse_proxy http://127.0.0.1:<NON_SSL_PORT>|reverse_proxy http://127.0.0.1:32768|g' /etc/openpanel/caddy/templates/domain.conf
sed -i 's|reverse_proxy https://127.0.0.1:<SSL_PORT>|reverse_proxy https://127.0.0.1:32769|g' /etc/openpanel/caddy/templates/domain.conf
But this is only for this domain/username.
Will wait for a permanent fix from you ASAP, not to have the same issue from now with other domains too