symfony-docker icon indicating copy to clipboard operation
symfony-docker copied to clipboard

Caddy status 308

Open prugala opened this issue 3 years ago • 1 comments

Hi

Im trying to use docker with default settings but I have problem with Caddy. When I open http://localhost I see in logs and its redirected to https: caddy_1 | {"level":"info","ts":1624120499.2699866,"logger":"http.log.access","msg":"handled request","request":{"remote_addr":"172.24.0.1:63136","proto":"HTTP/1.1","method":"GET","host":"localhost","uri":"/","headers":{"Accept-Encoding":["gzip, deflate, br"],"Connection":["keep-alive"],"User-Agent":["PostmanRuntime/7.28.0"],"Accept":["*/*"],"Postman-Token":["65af7e24-1463-4faf-9998-810878920dc4"]}},"common_log":"172.24.0.1 - - [19/Jun/2021:16:34:59 +0000] \"GET / HTTP/1.1\" 308 0","duration":0.0001331,"size":0,"status":308,"resp_headers":{"Content-Type":[],"Server":["Caddy"],"Connection":["close"],"Location":["https://localhost/"]}}

When I open https://localhost I dont see any logs.

Of course, website doesn't work. I see in Postman: Error: connect ECONNREFUSED 127.0.0.1:443

Macos 11.4 Docker version 20.10.7, build f0df350

prugala avatar Jun 19 '21 16:06 prugala

Same problem with older mac version and same docker version. I'm adding the docker-symfony files to an existing project, simply copying the content of this repo into the project (minus some filepaths), and following directions at Installing on an Existing Project.

After running docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d:

Port 80 is fine, and I'd expect the redirect to 443.

$ curl -v http://localhost/
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 308 Permanent Redirect
< Connection: close
< Location: https://localhost/
< Server: Caddy
< Date: Wed, 09 Mar 2022 21:57:49 GMT
< Content-Length: 0
<
* Closing connection 0

But nothing is listening on 443:

$ curl -v https://localhost/
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 443 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connection failed
* connect to 127.0.0.1 port 443 failed: Connection refused
* Failed to connect to localhost port 443: Connection refused
* Closing connection 0
curl: (7) Failed to connect to localhost port 443: Connection refused

@prugala, did you happen to find a fix for this?

johnpancoast avatar Mar 09 '22 21:03 johnpancoast

I'm facing the same issue when I access localhost:

{"level":"error","ts":1661311962.851015,"logger":"http.log.access","msg":"handled request","request":{"remote_ip":"172.22.0.1","remote_port":"34176","proto":"HTTP/2.0","method":"GET","host":"localhost","uri":"/","headers":{"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.9"],"Sec-Fetch-Site":["cross-site"],"Sec-Fetch-Mode":["navigate"],"Accept-Encoding":["gzip, deflate, br"],"Cache-Control":["max-age=0"],"Sec-Ch-Ua":["\"Chromium\";v=\"104\", \" Not A;Brand\";v=\"99\", \"Google Chrome\";v=\"104\""],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"],"Accept-Language":["en-GB,en-US;q=0.9,en;q=0.8"],"Sec-Ch-Ua-Mobile":["?0"],"Cookie":[],"Sec-Ch-Ua-Platform":["\"Windows\""],"Sec-Fetch-User":["?1"],"Sec-Fetch-Dest":["document"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"localhost"}},"user_id":"","duration":0.0003011,"size":0,"status":404,"resp_headers":{"Server":["Caddy"],"Alt-Svc":["h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"]}}

I'm on Docker 3.3.1 with WSL2.

Thanks

grenoult avatar Aug 24 '22 03:08 grenoult

@prugala The redirection is normal because caddy automatically redirects to https and informs you with a log info. It's also normal to not see any log when you try with "https" because he don't need to redirect you. Now for the website doesn't work, you should have some tls trust issues, see here : https://github.com/dunglas/symfony-docker/blob/main/docs/troubleshooting.md#fix-chromebrave-ssl

@grenoult Without having created a route / after the installation your 404 error is normal.

maxhelias avatar Sep 16 '22 09:09 maxhelias