Reputation: 41
I have hosted React Frontend app as a client on Coolify and hosted a Rails Backend api app as a server with PostgresSQL and Redis on Coolify as well. It's working fine locally but not working on production and uat environments on coolify. Can anyone please help me? Do I need some kind of Proxy adjustment or sth else? I have been stuck here for a week now. I'd really appreciate your help. Thank you so much!
I have twisted the CORS config and also the Proxy of the Caddyfile. But I am not going anywhere.
I am also getting this message in Proxy logs every 5 seconds.
2024-11-24T14:00:25.043139001Z {"level":"info","ts":1732456825.0429814,"logger":"docker-proxy","msg":"Process Caddyfile","logs":"[ERROR] Removing invalid block: parsing caddyfile tokens for 'handle_path': path matcher must begin with '/', got http://uat.api.meritbox.me*, at Caddyfile:4\n:// {\n\tencode zstd gzip\n\thandle_path http://uat.api.meritbox.me* {\n\t\treverse_proxy 10.0.3.5\n\t}\n\thandle_path http://www.uat.api.meritbox.me* {\n\t\treverse_proxy 10.0.3.5\n\t}\n\thandle_path https://www.uat.api.meritbox.me* {\n\t\treverse_proxy 10.0.3.5\n\t}\n\theader -Server\n\ttry_files {path} /index.html /index.php\n}\n\n"}
2024-11-24T14:00:30.045719445Z {"level":"info","ts":1732456830.045587,"logger":"docker-proxy","msg":"Process Caddyfile","logs":"[ERROR] Removing invalid block: parsing caddyfile tokens for 'handle_path': path matcher must begin with '/', got http://uat.api.meritbox.me*, at Caddyfile:4\n:// {\n\tencode zstd gzip\n\thandle_path http://uat.api.meritbox.me* {\n\t\treverse_proxy 10.0.3.5\n\t}\n\thandle_path http://www.uat.api.meritbox.me* {\n\t\treverse_proxy 10.0.3.5\n\t}\n\thandle_path https://www.uat.api.meritbox.me* {\n\t\treverse_proxy 10.0.3.5\n\t}\n\theader -Server\n\ttry_files {path} /index.html /index.php\n}\n\n"}
I now got this popup. Popup
And this is my twisted Caddy config.
networks:
coolify:
external: true
services:
caddy:
container_name: coolify-proxy
image: 'lucaslorentz/caddy-docker-proxy:2.8-alpine'
restart: unless-stopped
extra_hosts:
- 'host.docker.internal:host-gateway'
environment:
- CADDY_DOCKER_POLLING_INTERVAL=5s
- CADDY_DOCKER_CADDYFILE_PATH=/dynamic/Caddyfile
networks:
- coolify
ports:
- '80:80'
- '443:443'
- '443:443/udp'
labels:
- coolify.managed=true
- coolify.proxy=true
- "caddy=
# Production Environment
api.meritbox.me {
encode zstd gzip
handle /* {
reverse_proxy 10.0.3.2 {
header_up Host {upstream_hostport}
header_up X-Real-IP {remote_host}
header_up X-Forwarded-For {remote_host}
header_up X-Forwarded-Proto {scheme}
}
}
header {
Access-Control-Allow-Origin https://meritbox.me
Access-Control-Allow-Methods 'GET, POST, PUT, PATCH, DELETE, OPTIONS'
Access-Control-Allow-Headers 'Content-Type, Authorization, access-token, expiry, token-type'
Access-Control-Allow-Credentials true
Access-Control-Expose-Headers 'access-token, expiry, token-type, Authorization'
-Server
}
try_files {path} /index.html /index.php
}
www.api.meritbox.me {
redir https://api.meritbox.me{uri} permanent
}
# UAT Environment
uat.api.meritbox.me {
encode zstd gzip
handle /* {
reverse_proxy 10.0.3.5 {
header_up Host {upstream_hostport}
header_up X-Real-IP {remote_host}
header_up X-Forwarded-For {remote_host}
header_up X-Forwarded-Proto {scheme}
}
}
header {
Access-Control-Allow-Origin https://uat.meritbox.me
Access-Control-Allow-Methods 'GET, POST, PUT, PATCH, DELETE, OPTIONS'
Access-Control-Allow-Headers 'Content-Type, Authorization, access-token, expiry, token-type'
Access-Control-Allow-Credentials true
Access-Control-Expose-Headers 'access-token, expiry, token-type, Authorization'
-Server
}
try_files {path} /index.html /index.php
}
www.uat.api.meritbox.me {
redir https://uat.api.meritbox.me{uri} permanent
}"
volumes:
- '/var/run/docker.sock:/var/run/docker.sock:ro'
- '/data/coolify/proxy/caddy/dynamic:/dynamic'
- '/data/coolify/proxy/caddy/config:/config'
- '/data/coolify/proxy/caddy/data:/data'
Upvotes: 1
Views: 209