Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!