Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot start docker nginx

My operating system is windows 10 with latest Docker Desktop and the app is running on node 16(docker nodejs)

Here is my nginx conf file at: ./nginx/default.conf(windows 10 machine)

server {
listen 80;

location /users {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass http://pwm-node:3000
    proxy_redirect off;
}

}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

here is my docker-compose.yml:

version: '3'
services:
  nginx:
    image: nginx:stable-alpine
    ports:
      - "3000:80" # nginx listen on 80
    volumes:
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro

  pwm-node:
    build: .
    environment:
      - PORT=3000
    depends_on:
      - mongo

  mongo:
    image: mongo
    environment:
      - MONGO_INITDB_ROOT_USERNAME=superuser
      - MONGO_INITDB_ROOT_PASSWORD=superuser
    volumes:
      - mongo-db:/data/db

  redis:
    image: redis
volumes:
  mongo-db:

Here is the logs of nginx container fail to start:

2021-12-20T11:50:31.262794400Z  /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
2021-12-20T11:50:31.262861000Z  /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
2021-12-20T11:50:31.263500100Z  /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
2021-12-20T11:50:31.264787300Z  10-listen-on-ipv6-by-default.sh: info: can not modify /etc/nginx/conf.d/default.conf (read-only file system?)
2021-12-20T11:50:31.264896600Z  /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
2021-12-20T11:50:31.266405000Z  /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
2021-12-20T11:50:31.267157100Z  /docker-entrypoint.sh: Configuration complete; ready for start up
2021-12-20T11:50:31.269871700Z  2021/12/20 11:50:31 [emerg] 1#1: invalid number of arguments in "proxy_pass" directive in /etc/nginx/conf.d/default.conf:11
2021-12-20T11:50:31.269880300Z  nginx: [emerg] invalid number of arguments in "proxy_pass" directive in /etc/nginx/conf.d/default.conf:11

>Solution :

That’s easy: You are missing a semicolon within nginx/default.conf, you have to write:

proxy_pass http://pwm-node:3000;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading