@francislavoie I’m adding an architecture image to explain myself better. I understand what you are saying about 0.0.0.0, and I do indeed want the request to happen in the UI container because that’s the only way to access the private API in the cluster. So what I am wanting to achieve is that when the UI has to query the API /api/v1/myEndpoint that it sends it to the API container that is listening on port 3000. I’m also doing all my testing on the actual environment to remove issues related to local environment.
The moment the landing page / is presented, a request to the API is invoked.
I can see from Caddy logs that whenever I visit the UI URL that it’s serving the requests. But nothing in the logs displays an attempt to handle the /api/* path. I’m attaching the logs you mentioned above.
curl logs:
curl -v http://a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080
* Trying 34.200.190.177:8080...
* Connected to a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com (34.200.190.177) port 8080 (#0)
> GET / HTTP/1.1
> Host: a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 726
< Content-Type: text/html; charset=utf-8
< Etag: "rola6rk6"
< Last-Modified: Mon, 16 Jan 2023 17:35:15 GMT
< Server: Caddy
< Date: Wed, 18 Jan 2023 16:34:40 GMT
<
* Connection #0 to host a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com left intact
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="A Spectro Cloud demo application. Visit https://spectrocloud.com for more information."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><script src="/env.js"></script><title>Spectro Cloud</title><script defer="defer" src="/static/js/main.3f926c94.js"></script><link href="/static/css/main.2dc3ef71.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>%
Caddy logs:
{"level":"info","ts":"2023/01/18 16:34:40","logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"10.0.208.128","remote_port":"15859","proto":"HTTP/1.1","method":"GET","host":"a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080","uri":"/","headers":{"User-Agent":["curl/7.85.0"],"Accept":["*/*"]}},"user_id":"","duration":0.000517349,"size":726,"status":200,"resp_headers":{"Server":["Caddy"],"Etag":["\"rola6rk6\""],"Content-Type":["text/html; charset=utf-8"],"Last-Modified":["Mon, 16 Jan 2023 17:35:15 GMT"],"Accept-Ranges":["bytes"],"Content-Length":["726"]}}
{"level":"info","ts":"2023/01/18 16:35:29","logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"10.0.208.128","remote_port":"26780","proto":"HTTP/1.1","method":"GET","host":"a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080","uri":"/","headers":{"Connection":["keep-alive"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"],"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"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9"]}},"user_id":"","duration":0.000876755,"size":414,"status":200,"resp_headers":{"Vary":["Accept-Encoding"],"Server":["Caddy"],"Etag":["\"rola6rk6\""],"Content-Type":["text/html; charset=utf-8"],"Last-Modified":["Mon, 16 Jan 2023 17:35:15 GMT"],"Content-Encoding":["gzip"]}}
{"level":"info","ts":"2023/01/18 16:35:30","logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"10.0.208.128","remote_port":"26780","proto":"HTTP/1.1","method":"GET","host":"a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080","uri":"/env.js","headers":{"Referer":["http://a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080/"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"],"Accept":["*/*"]}},"user_id":"","duration":0.000097755,"size":186,"status":200,"resp_headers":{"Accept-Ranges":["bytes"],"Content-Length":["186"],"Server":["Caddy"],"Etag":["\"roowni56\""],"Content-Type":["text/javascript; charset=utf-8"],"Last-Modified":["Wed, 18 Jan 2023 16:33:18 GMT"]}}
{"level":"info","ts":"2023/01/18 16:35:30","logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"10.0.208.128","remote_port":"26780","proto":"HTTP/1.1","method":"GET","host":"a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080","uri":"/static/css/main.2dc3ef71.css","headers":{"Referer":["http://a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080/"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"],"Accept":["text/css,*/*;q=0.1"]}},"user_id":"","duration":0.000658718,"size":705,"status":200,"resp_headers":{"Server":["Caddy"],"Etag":["\"rola6r13a\""],"Content-Type":["text/css; charset=utf-8"],"Last-Modified":["Mon, 16 Jan 2023 17:35:15 GMT"],"Content-Encoding":["gzip"],"Vary":["Accept-Encoding"]}}
{"level":"info","ts":"2023/01/18 16:35:30","logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"10.0.208.128","remote_port":"56122","proto":"HTTP/1.1","method":"GET","host":"a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080","uri":"/static/js/main.3f926c94.js","headers":{"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"],"Accept":["*/*"],"Referer":["http://a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080/"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9"]}},"user_id":"","duration":0.09909016,"size":96022,"status":200,"resp_headers":{"Vary":["Accept-Encoding"],"Server":["Caddy"],"Etag":["\"rola6r5fv7\""],"Content-Type":["text/javascript; charset=utf-8"],"Last-Modified":["Mon, 16 Jan 2023 17:35:15 GMT"],"Content-Encoding":["gzip"]}}
{"level":"info","ts":"2023/01/18 16:35:30","logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"10.0.208.128","remote_port":"56122","proto":"HTTP/1.1","method":"GET","host":"a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080","uri":"/static/media/logo.c051b85956a838a03746c752d6254cf0.svg","headers":{"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"],"Referer":["http://a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080/"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9"],"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"]}},"user_id":"","duration":0.000226276,"size":354,"status":200,"resp_headers":{"Server":["Caddy"],"Etag":["\"rola6rhp\""],"Content-Type":["image/svg+xml"],"Last-Modified":["Mon, 16 Jan 2023 17:35:15 GMT"],"Content-Encoding":["gzip"],"Vary":["Accept-Encoding"]}}
{"level":"info","ts":"2023/01/18 16:35:30","logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"10.0.208.128","remote_port":"56122","proto":"HTTP/1.1","method":"GET","host":"a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080","uri":"/favicon.ico","headers":{"Connection":["keep-alive"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"],"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"],"Referer":["http://a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080/"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9"]}},"user_id":"","duration":0.000212003,"size":14582,"status":200,"resp_headers":{"Content-Type":["image/x-icon"],"Last-Modified":["Mon, 16 Jan 2023 17:34:27 GMT"],"Accept-Ranges":["bytes"],"Content-Length":["14582"],"Server":["Caddy"],"Etag":["\"rola5fb92\""]}}
{"level":"info","ts":"2023/01/18 16:39:27","logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"10.0.208.128","remote_port":"34545","proto":"HTTP/1.1","method":"GET","host":"a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080","uri":"/","headers":{"Upgrade-Insecure-Requests":["1"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9"],"Connection":["keep-alive"],"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"],"If-None-Match":["\"rola6rk6\""],"If-Modified-Since":["Mon, 16 Jan 2023 17:35:15 GMT"],"Cache-Control":["max-age=0"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"]}},"user_id":"","duration":0.000197508,"size":0,"status":304,"resp_headers":{"Server":["Caddy"],"Etag":["\"rola6rk6\""]}}
{"level":"info","ts":"2023/01/18 16:39:27","logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"10.0.208.128","remote_port":"34545","proto":"HTTP/1.1","method":"GET","host":"a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080","uri":"/env.js","headers":{"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"],"If-None-Match":["\"roowni56\""],"Accept-Encoding":["gzip, deflate"],"If-Modified-Since":["Wed, 18 Jan 2023 16:33:18 GMT"],"Connection":["keep-alive"],"Accept":["*/*"],"Referer":["http://a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080/"],"Accept-Language":["en-US,en;q=0.9"]}},"user_id":"","duration":0.000116058,"size":0,"status":304,"resp_headers":{"Server":["Caddy"],"Etag":["\"roowni56\""]}}
Caddy server logs
{"level":"info","ts":1674059600.0216062,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
{"level":"warn","ts":1674059600.0231373,"msg":"Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":10}
{"level":"info","ts":1674059600.0239792,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
{"level":"info","ts":1674059600.0303643,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000156e00"}
{"level":"info","ts":1674059600.1193013,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
{"level":"info","ts":1674059600.1194797,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/home/appuser/.local/share/caddy"}
{"level":"info","ts":1674059600.1195548,"msg":"autosaved config (load with --resume flag)","file":"/home/appuser/.config/caddy/autosave.json"}
{"level":"info","ts":1674059600.1195657,"msg":"serving initial configuration"}
{"level":"info","ts":1674059600.1195931,"logger":"tls","msg":"finished cleaning storage units"}
{"level":"info","ts":1674059943.8195412,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_ip":"127.0.0.1","remote_port":"38466","headers":{"Accept-Encoding":["gzip"],"Content-Length":["1120"],"Content-Type":["application/json"],"Origin":["http://localhost:2019"],"User-Agent":["Go-http-client/1.1"]}}
{"level":"info","ts":1674059943.8203928,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
{"level":"info","ts":1674059943.820684,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000614bd0"}
{"level":"debug","ts":1674059943.8208182,"logger":"http","msg":"starting server loop","address":"[::]:8080","tls":false,"http3":false}
{"level":"info","ts":1674059943.82085,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
{"level":"info","ts":1674059943.82095,"logger":"tls.cache.maintenance","msg":"stopped background certificate maintenance","cache":"0xc000156e00"}
{"level":"info","ts":1674059943.9192686,"msg":"autosaved config (load with --resume flag)","file":"/home/appuser/.config/caddy/autosave.json"}
{"level":"info","ts":1674059943.9193323,"logger":"admin.api","msg":"load complete"}
{"level":"info","ts":1674059943.9577994,"logger":"admin","msg":"stopped previous server","address":"localhost:2019"}
{"level":"debug","ts":1674059967.4957237,"logger":"http.handlers.rewrite","msg":"rewrote request","request":{"remote_ip":"10.0.208.128","remote_port":"34545","proto":"HTTP/1.1","method":"GET","host":"a876bdf3cb30749528538d3374d5c06c-834139808.us-east-1.elb.amazonaws.com:8080","uri":"/","headers":{"Accept-Language":["en-US,en;q=0.9"],"Connection":["keep-alive"],"Upgrade-Insecure-Requests":["1"],"Accept-Encoding":["gzip, deflate"],"If-Modified-Since":["Mon, 16 Jan 2023 17:35:15 GMT"],"Cache-Control":["max-age=0"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"],"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"],"If-None-Match":["\"rola6rk6\""]}},"method":"GET","uri":"/index.html"}
{"level":"debug","ts":1674059967.4957592,"logger":"http.handlers.file_server","msg":"sanitized path join","site_root":"/app/build","request_path":"/index.html","result":"/app/build/index.html"}
{"level":"debug","ts":1674059967.4957747,"logger":"http.handlers.file_server","msg":"opening file","filename":"/app/build/index.html"}
{"level":"debug","ts":1674059967.5952854,"logger":"http.handlers.file_server","msg":"sanitized path join","site_root":"/app/build","request_path":"/env.js","result":"/app/build/env.js"}
{"level":"debug","ts":1674059967.595322,"logger":"http.handlers.file_server","msg":"opening file","filename":"/app/build/env.js"}