Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Nginx not find services in preview deployment #3511

Open
picheidt opened this issue Sep 19, 2024 · 0 comments
Open

[Bug]: Nginx not find services in preview deployment #3511

picheidt opened this issue Sep 19, 2024 · 0 comments
Labels
🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization.

Comments

@picheidt
Copy link

picheidt commented Sep 19, 2024

Error Message and Logs

I have a PHP application using nginx as a reverse proxy. I deploy it with Coolify and Docker Compose, and the main deployment works as expected. However, the preview deployment results in the following error:

error: nginx: [emerg] host not found in upstream "php_mm2" in /etc/nginx/conf.d/default.conf:16

Below are my current files

  • DockerFile.nginx
FROM nginx:stable-alpine

WORKDIR /var/www/html/

COPY ./webroot /var/www/html
COPY ./docker/nginx/default.conf /etc/nginx/conf.d/default.conf

EXPOSE 80/tcp
  • nginx.conf
server {
    listen 80;
    index index.php index.html;
    server_name localhost;
    error_log /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/html;

    location / {
    	try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ˆ(.+\.php)(/.+)$;
        fastcgi_pass php_mm2:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}
  • docker-compose
services:
  nginx_mm2:
    build:
      context: .
      dockerfile: Dockerfile.nginx.staging
    container_name: nginx_mm2
    ports:
      - "80"
    depends_on:
      - php_mm2
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:80/app/healthCheck" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 15s
  
  php_mm2:
    build:
      context: .
      dockerfile: Dockerfile.staging
    container_name: php_mm2
    command: sh ./run_dependencies_staging.sh
    ports:
      - "9000"

Steps to Reproduce

  1. Active preview deployment
  2. Use docker-compose with an application and nginx containers
  3. Open a PR to trigger the preview Deployment

Example Repository URL

No response

Coolify Version

v4.0.0-beta.338

Are you using Coolify Cloud?

No (self-hosted)

Operating System and Version (self-hosted)

Ubuntu 22.04.4 LTS

Additional Information

The application and nginx containers are on the same network. I couldn’t debug nginx because it keeps restarting in a loop due to the error.

I think the reason is that during the preview deployment, the service name is changed with the addition of pr-{prId}.
image

@picheidt picheidt added 🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization. labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization.
Projects
None yet
Development

No branches or pull requests

1 participant