Reputation: 612
I'm trying to implement a Django / Gunicorn / Nginx dockerized. For Django gunicorn and postgresql everything works very well. But Nginx decided to not work.
I made a custom Nginx config file which gave me the error:
unknown directive "server"
So I changed it at the maximum to try it with docker run in place of docker compose. I did a Dockerfile because it seems that the volume mount didn't work but same result.
Here is the dockerfile:
FROM nginx:1.19.0-alpine
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
And the nginx.conf
server {
listen 80;
location / {
proxy_pass http://127.0.0.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
}
Pretty simple. But still if I try to run this docker:
docker build -t nginx .
docker run nginx
Still the same error.
Here is the full logs on the run command:
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: Getting the checksum of /etc/nginx/conf.d/default.conf 10-listen-on-ipv6-by-default.sh: /etc/nginx/conf.d/default.conf differs from the packages version, exiting /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh /docker-entrypoint.sh: Configuration complete; ready for start up 2021/02/06 13:58:21 [emerg] 1#1: unknown directive "upstream" in /etc/nginx/conf.d/default.conf:1 nginx: [emerg] unknown directive "upstream" in /etc/nginx/conf.d/default.conf:1
I spend almost 6 hours on that and probably read half of StackOverflow with no result.
Any life saving idea?
Upvotes: 0
Views: 1079
Reputation: 11
I had a case where I had to change encoding from UTF-8 with BOM to UTF-8 in VS Code for it to work
Upvotes: 1
Reputation: 612
Ok Finally got it.
I removed the complete .conf file and did it without copy paste directly with vim and that works.
It seems that PyCharm saved it with a problem.
Upvotes: 0