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. The whole codes are the same so I am so confused why it is not working as the other.
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 (the left one server is my droplet, the right one is my other server) my droplet is not listening to 80 port normally it should listen as the other server.
my other server:
root@cihatserver:/home/cihat/app# netstat -plant | grep 80
output is: tcp6 0 0 :::80 :::* LISTEN 15696/docker-proxy
my droplet :
root@knowin-project-dev:/home/cihat/app# netstat -plant | grep 80
output is: –empty–
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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hi there,
The error reports that the
enable
directive on line 45 is causing the problem but that line is commented out. The possible problem would be if you are using an old image that has theenable
directive still not commented out.I could suggest trying to rebuild the image and run the container again. I’ve just tested this with the Nginx config file that you’ve shared and the Dockerfile and it worked as expected.
Let me know how it goes. Regards, Bobby