Score:0

Nginx with Docker : nginx: [emerg] unknown directive "enable" in /etc/nginx/nginx.conf

ms flag

I have 2 servers one is on the Digital ocean the other is somewhere else. I have one project and it is working well with all apps on that server. But, I wanted to create a droplet and move it to the digital ocean so I was copied all files to the new server(digital ocean) via sudo scp command. All services are working well except Nginx is returning Exit code 1 as below image. The whole codes are the same so I am so confused why it is not working as the other.

services

May I know what might I am missing?

it is my nginx.conf file :

worker_processes 4;
    
    events {
      worker_connections 4096;
    }
    
    http {
    
      server {
        listen 80 default_server;
        server_name "";
        return 444;
      }
    
      server {
        server_name game-dev.myappapp.com;
    
        location / {
          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_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
    
          proxy_pass http://game_nodes;
          proxy_redirect off;
        }
      }
      server {
        if ($host = game-dev.myappapp.com) {
          return 301 https://$host$request_uri;
        }
    
    
        listen 80;
        listen [::]:80;
        server_name game-dev.myappapp.com;
        return 404;
      }
    
      upstream game_nodes {
        # enable sticky session
        #ip_hash;
        server game-alpha:3000;
        keepalive 8;
      }
    
      server {
        server_name api-dev.myappapp.com;
    
        location / {
          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://main_nodes;
          proxy_redirect off;
    
        }
      }
    
      server {
        if ($host = api-dev.myappapp.com) {
          return 301 https://$host$request_uri;
        }
    
        listen 80;
        listen [::]:80;
        server_name api-dev.myappapp.com;
        return 404;
      }
    
      upstream main_nodes {
        server main-alpha:8000;
        server main-beta:8000;
        keepalive 8;
      }
    }

it is my Dockerfile :

FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf

As you can see from below screenshot (the left server is my droplet, the right one is my other server) my droplet is not listening to 80 port normally it should listen to 80 port the other server.

screenshot

This is my Nginx log.

root@knowin-project-dev:/home/cihat/app# docker logs nginx
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/06/13 20:22:46 [emerg] 1#1: unknown directive "enable" in /etc/nginx/nginx.conf:45
nginx: [emerg] unknown directive "enable" in /etc/nginx/nginx.conf:45

Note: ufw's status is inactive. So all ports are available.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.