Coolify + Nginx = ❤️
Written by haloboy777 on 2024-12-20
Nginx configuration for Coolify
I recently deployed Coolify on my server and wanted to share the Nginx configuration I used to make it work.
Here's the Nginx configuration I used:
server {
server_name <HOST_NAME>;
# ACME Challenge for Certbot
location ~ "^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)$" {
default_type text/plain;
return 200 "$1.<CERTBOT_CHALLENGE>";
}
listen 443 ssl; # managed by Certbot
ssl_certificate [CERT_PATH]; # managed by Certbot
ssl_certificate_key [CERT_PATH]; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
add_header Strict-Transport-Security "max-age=7200";
# Handle /app/* requests
location /app/ {
proxy_pass http://127.0.0.1:6001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-Proto https;
}
# Handle /terminal/ws requests
location /terminal/ws {
proxy_pass http://127.0.0.1:6002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-Proto https;
}
# Handle all other traffic
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-Proto https;
}
}
server {
if ($host = <HOST_NAME>) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name <HOST_NAME>;
listen 80;
return 404; # managed by Certbot
}