Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
Nginx fails to start with no logs

I'm trying to run Nginx in docker, but the Nginx keeps failing.

Nginx config file:

worker_processes 1;
error_log  /var/log/nginx/my_error.log;
pid        /var/log/nginx/nginx.pid;

events {
  worker_connections 1024; # increase if you have lots of clients
  accept_mutex off; # set to 'on' if nginx worker_processes > 1
}

http {
  include mime.types;
  default_type application/octet-stream;
  sendfile on;

  upstream app_server {
    server localhost:5000 fail_timeout=0;
  }

  server {
    client_max_body_size 4G;

    location @proxy_to_app {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header Host $http_host;
      # we don't want nginx trying to do something clever with
      # redirects, we set the Host: header above already.
      proxy_redirect off;
      proxy_pass http://localhost:5000;
    }

    listen 443 ssl; 
    ssl_certificate /etc/ssl/certificate.pem;
    ssl_certificate_key /etc/ssl/key.pem;
    }
}

Dockerfile:

RUN apt-get update && apt-get install -y nginx
COPY ssl/certificate.pem /etc/ssl/certificate.pem
COPY ssl/key.pem /etc/ssl/key.pem
COPY nginx_configuration/nginx.conf /etc/nginx/nginx.conf
EXPOSE 443
EXPOSE 5000
RUN /etc/init.d/nginx start
CMD ["python3",  "my_app"]

But when I check the nginx status:

/etc/init.d/nginx status
[FAIL] nginx is not running ... failed!

When I run:

/etc/init.d/nginx start

Everything works as expected.

I checked the log files, there are all empty.

Thanks, Omer

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This line is only being executed during image creation. So when a container is created "it does nothing"

RUN /etc/init.d/nginx start

What you are really running inside your container is this python script. I think there is no reference to it in your question.

CMD ["python3",  "my_app"]

You can use the following Dockerfile

FROM nginx
COPY ssl/certificate.pem /etc/ssl/certificate.pem
COPY ssl/key.pem /etc/ssl/key.pem
COPY nginx_configuration/nginx.conf /etc/nginx/nginx.conf
EXPOSE 443
EXPOSE 5000
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda