EC2 + LoadBalancer + Subdomains not Working

1. The problem I’m having:

I have a server using an EC2 with Amazon Linux 2. It runs behind an auto-scaling group, with a load balancer, and is a subdomain.
I performed the settings but got 308 e in the browser (to_many_redirects).

2. Error messages and/or full log output:

● caddy.service - Caddy
Loaded: loaded (/etc/systemd/system/caddy.service; disabled; vendor preset: disabled)
Active: active (running) since seg 2023-07-17 08:17:15 -03; 2h 34min ago
Main PID: 6689 (caddy)
CGroup: /system.slice/caddy.service
└─6689 /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile

jul 17 10:50:55 ip-172-31-16-62.us-west-2.compute.internal caddy[6689]: {“level”:“info”,“ts”:1689601855.9096808,“logger”:“http.log.access”,“msg”:“handled request”,“request”:{“remote_ip”:“172.31.47.168”,“remote_port”:“17436”,“proto”:“HTTP/1.1”,“method”:“GET”,“host”:"multitenancy.abracadraba.com.br",“uri”:“/”,“headers”:{“Sec-Ch-Ua-Mobile”:[“?0”],“Accept-Language”:[“pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7”],“Cookie”:[],“X-Forwarded-Port”:[“443”],“User-Agent”:[“Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36”],“Sec-Fetch-Site”:[“none”],“Sec-Fetch-Dest”:[“document”],“Accept”:[“text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7”],“Accept-Encoding”:[“gzip, deflate, br”],“Sec-Ch-Ua-Platform”:[“"Linux"”],“X-Amzn-Trace-Id”:[“Root=1-64b5473f-60f32b302a5e1fee21ff2fa8”],“Cache-Control”:[“max-age=0”],“Sec-Fetch-Mode”:[“navigate”],“Sec-Fetch-User”:[“?1”],“Sec-Ch-Ua”:[“"Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110"”],“X-Forwarded-For”:[“187.95.86.249”],“X-Forwarded-Proto”:[“https”],“Upgrade-Insecure-Requests”:[“1”]}},“user_id”:“”,“duration”:0.00003624,“size”:0,“status”:308,“resp_headers”:{“Connection”:[“close”],“Location”:["https://multitenancy.abracadraba.com.br/"],“Content-Type”:[],“Server”:[“Caddy”]}}
jul 17 11:00:53 ip-172-31-16-62.us-west-2.compute.internal caddy[6689]: {“level”:“error”,“ts”:1689602453.2386646,“logger”:“http.acme_client”,“msg”:“validating authorization”,“identifier”:"www.multitenancy.smartlms.com.br",“problem”:{“type”:“urn:ietf:params:acme:error:dns”,“title”:“”,“detail”:“DNS problem: NXDOMAIN looking up A for www.multitenancy.abracadraba.com.br- check that a DNS record exists for this domain; DNS problem: NXDOMAIN looking up AAAA for www.multitenancy.abracadra.com.br - check that a DNS record exists for this domain”,“instance”:“”,“subproblems”:[]},“order”:“https://acme-v02.api.letsencrypt.org/acme/order/1211080297/195516728807”,“attempt”:1,“max_attempts”:3}

3. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy

https://caddyserver.com/docs/running

a. System environment:

Amazon Linux 2

b. Command:

systemctl start caddy
systemctl reload caddy (for new inserts in CaddyFile)

d. My complete Caddy config:

debug{

www.multitenancy.abracadabra.com.br {
# Set this path to your site’s directory.
#tls /etc/caddy/cert.pem /etc/caddy/key.pem
#order foward_proxy before file_server
#reverse_proxy 127.0.0.1:9000
log
#root * /var/www/multitenancy.abracadraba.com.br/public
#php_fastcgi 127.0.0.1:9000
encode gzip
#php_fastcgi unix//run/php-fpm/php-fpm.sock
# Enable the static file server.
file_server
root * /var/www/multitenancy.abracadraba.com.br/public
# 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
}
}

Refer to the Caddy docs for more information:

The Caddyfile — Caddy Documentation

5. Links to relevant resources:

Please mind your post’s formatting. It’s very difficult to read because you didn’t use code fences. Use the </> button to insert a code block.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.