Error etc nginx conf d default conf differs from the packaged version

Hello, I am trying to setup Rails application with ngnix, but no matter what I do I am always getting this error: nginx_1 | 10-listen-on-ipv6-by-default.sh: /etc/nginx/conf.d/default.conf differs f...

I am experiencing the same problem in a service run as docker swarm (docker stack deploy)
the error was «No route to host», after surfing and searching I found that nginx service was ready before the companion service (php fpm), I just stopped the container and the swarm controller restart a new one, this fixed the problem.
I have no idea on how to solve this (there is a solution in docker.com site, actually), but I think it is not correct this upfront resolution of ip address in a docker environment.

I mean, why nginx resolve address name once at start and not ask for resolver every time? If I had removed the service then deployed it again that would have not worked, because the nginx resolved with the old service address that changes everytime a service is restarted.

maybe https://medium.com/driven-by-code/dynamic-dns-resolution-in-nginx-22133c22e3ab would work?
I paste it here:

location / {
    resolver 10.0.0.2;
set $elb_dns internal-balancer-loader-2000–1525531520.us-west-2.elb.amazonaws.com;
proxy_pass $elb_dns;
}

(my case is fastcgi_pass), the author say «Nginx evaluates the value of the variable per-request, instead of just once at startup.», and it is workaround way

I’m trying to set up a web server with multiple containers — but starting with a simple setup for my reverse proxy.

My docker-compose.yml looks as follows:

version: '3'

services:
    reverse-proxy:
        container_name: reverse-proxy
        hostname: reverse-proxy
        image: nginx:latest
        ports:
        - 80:80
        volumes:
        - ./nginx-config/conf.d:/etc/nginx/conf.d
        - ./html:/usr/share/nginx/html
        environment:
            - NGINX_PORT=80
            - ENV=development

Having nginx-config folder structure like:

nginx-config
|- templates
  |-default.conf.template
  |- sites-available
    |- mysite.conf.template

And default.conf.template that looks like:

server {
    listen       ${NGINX_PORT} default_server;
    listen  [::]:${NGINX_PORT} default_server;
    
    server_name  _;
    root   /usr/share/nginx/html;

    charset UTF-8;

    error_page 404 /notfound.html;
    location = /notfound.html {
        allow   all;
    }
    location / {
        return 404;
    }

    access_log off;
    log_not_found off;
    error_log  /var/log/nginx/error.log error;
}

However, whenever I run docker-compose --context myremote up it doesn´t work, throwing the following output:

reverse-proxy    | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
reverse-proxy    | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
reverse-proxy    | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
reverse-proxy    | 10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
reverse-proxy    | 10-listen-on-ipv6-by-default.sh: /etc/nginx/conf.d/default.conf differs from the packaged version, exiting
reverse-proxy    | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
reverse-proxy    | /docker-entrypoint.sh: Configuration complete; ready for start up

It all generates the right output under nginx-config/conf.d/default.conf at least on my local machine.

Is there any way I can take advantage of custom config and templates using docker-compose without running into such an issue?

Добрый день.
Возникла проблема на рабочем сервере.
Создал образ docker на локальном, выгрузил на сервер.
Естественно сайт не запустился.
В логах docker на сервере ошибка

docker logs cont-nginx_1
/docker-entrypoint.sh: Configuration complete; ready for start up
2020/12/28 13:38:57 [emerg] 1#1: open() «/etc/nginx/fastcgi-params» failed (2: No such file or directory) in /etc/nginx/conf.d/default.conf:26
nginx: [emerg] open() «/etc/nginx/fastcgi-params» failed (2: No such file or directory) in /etc/nginx/conf.d/default.conf:26

Если посмотреть логи docker на локальном, то никакой ошибки нет и всё работает.

docker logs cont-nginx_1
/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: /etc/nginx/conf.d/default.conf differs from the packaged version
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Configuration complete; ready for start up

Образ собирался из

nginx:1.19-alpine

Конфигурация nginx

server{
    listen 80;
    server_name _;
    index index.php index.html;
    root /app/public;
    charset utf-8;

    add_header X-Frame-Options "SAMEORIGIN";

    location ~* .(?:ico|gif|jpe?g|png|woff2?|eot|otf|ttf|svg|js|css)$ {
        access_log off;
        expires max;
        add_header Pragma public;
        add_header Cache-Control "public";
        try_files $uri /index.php?$args;
    }

    location / {
       try_files $uri /index.php?$args;
    }

    location ~ .php$ {
       fastcgi_split_path_info ^(.+.php)(/.+)$;
       fastcgi_pass pohoron-php-fpm:9000;
       fastcgi_index index.php;
       include fastcgi-params;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

Куда пропал fastcgi-params? Как исправить ситуацию?

UPD

docker build --pull --file=site/docker/production/nginx.docker --tag ${REGISTRY_ADDRESS}:nginx-${IMAGE_TAG} site

docker push ${REGISTRY_ADDRESS}:nginx-${IMAGE_TAG}

scp -o StrictHostKeyChecking=no ${PORDUCTION_PORT} docker-compose-production.yml ${PRODUCTION_HOST}:docker-compose.yml
ssh -o StrictHostKeyChecking=no ${PRODUCTION_HOST} -p ${PRODUCTION_PORT} 'docker-compose pull'
ssh -o StrictHostKeyChecking=no ${PRODUCTION_HOST} -p ${PRODUCTION_PORT} 'docker-compose up --build -d'

docker-compose-production.yml

version: '3'
services:
  site-nginx:
    image: ${REGISTRY_ADDRESS}:nginx-${IMAGE_TAG}
    restart: always
    depends_on:
      - site-php-fpm
    ports:
    - "80:80"
  site-php-fpm:
    image: ${REGISTRY_ADDRESS}:php-fpm-${IMAGE_TAG}
    restart: always
    environment:
      DATABASE_URL: pgsql://app:${DB_PASSWORD}@site-postgres:5432/app
      OAUTH_FACEBOOK_SERCRET: ${OAUTH_FACEBOOK_SECRET}
      REDIS_URL: tcp://site-redis:6379?password=${REDIS_PASSWORD}
      MAILER_URL: null://localhost
    depends_on:
      - site-postgres
      - site-redis

  site-redis:
    image: ${REGISTRY_ADDRESS}:redis-${IMAGE_TAG}
    restart: always
    volumes:
    - site-redis:/data
    command: redis-server --requirepass ${REDIS_PASSWORD}

volumes:
  site-postgres:
  site-redis:

nginx-docker

FROM nginx:1.19-alpine
COPY ./docker/production/nginx/conf.d /etc/nginx/conf.d
WORKDIR /app
COPY ./public ./public
COPY --from=node-builder /app/public/build ./public/build


0

2

В целях изучения Docker взялся за связку php и nginx.
Связать их вместе не получилось.

Моя последовательность действий:

Запускаю контейнер с php первым (т.к nginx его потом использует):

sudo docker run -d --name php_container php:fpm

Создаю Dockerfile для nginx:

from nginx
COPY default.host /etc/nginx/conf.d/default.conf

Содержимое default.host:

server {
    listen 80 default;

    root /var/www/html;
    index index.php;

    location / {
        try_files $uri/ /index.php?$args;
    }

    location ~ .php$ {
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  SCRIPT_NAME $fastcgi_script_name;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        include fastcgi_params;
    }
}

Собираю образ с Nginx:

sudo docker build -t nginx_image .

Запускаю контейнер:

sudo docker run -p 80:80 --link php_container:php -v /home/yr/index.php:/var/www/html/index.php nginx_image

Перехожу на 0.0.0.0:80 и браузер выводит File not found.
В логах контейнера 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: /etc/nginx/conf.d/default.conf differs from the packaged version
/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/06 10:47:55 [notice] 1#1: using the "epoll" event method
2021/06/06 10:47:55 [notice] 1#1: nginx/1.21.0
2021/06/06 10:47:55 [notice] 1#1: built by gcc 8.3.0 (Debian 8.3.0-6) 
2021/06/06 10:47:55 [notice] 1#1: OS: Linux 5.12.8-300.fc34.x86_64
2021/06/06 10:47:55 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/06/06 10:47:55 [notice] 1#1: start worker processes
2021/06/06 10:47:55 [notice] 1#1: start worker process 30
2021/06/06 10:47:55 [notice] 1#1: start worker process 31
2021/06/06 10:47:55 [notice] 1#1: start worker process 32
2021/06/06 10:47:55 [notice] 1#1: start worker process 33
2021/06/06 10:48:14 [error] 31#31: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.17.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://172.17.0.2:9000", host: "0.0.0.0"
172.17.0.1 - - [06/Jun/2021:10:48:14 +0000] "GET / HTTP/1.1" 404 27 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36" "-"

How to Install Nginx and Let’s Encrypt with Docker – Ubuntu 20.04. In this guide you are going to learn how to install and configure Nginx with Let’s Encrypt SSL using Docker and Docker Compose on Ubuntu 20.04.

In this tutorial we will use latest Nginx image and latest Certbot image and setup validation and finally configure SSL with a basic HTML site served using Nginx.

This installation and setup is tested on Google Cloud Compute Engine running Ubuntu 20.04 with Docker and Docker Compose. So this setup will work on other cloud service providers like AWS or Digital Ocean or Azure or any VPS or Dedicated servers.

Prerequisites

  • Running Compute Engine, see the Setting up Compute Engine Instance.
  • Follow this guide to Install Docker on Ubuntu 20.04.
  • For managing containers install Docker Compose on your server.
  • Configure DNS to point the domain to the server to install SSL.

Once you have all the prerequisites done you can proceed to make the setup and install SSL.

Create Docker Compose YML file

Now SSH inside your server or Virtual machine and create a directory to hold all the configurations by running the following command.

sudo mkdir ~/nginx-ssl

Move inside the directory and create a docker-compose.yml file that holds our configuration.

cd ~/nginx-ssl
sudo nano ~/nginx-ssl/docker-compose.yml

Paste the following configurations inside the file.

version: "3.8"
services:
    web: 
        image: nginx:latest
        restart: always
        volumes:
            - ./public:/var/www/html
            - ./conf.d:/etc/nginx/conf.d
            - ./certbot/conf:/etc/nginx/ssl
            - ./certbot/data:/var/www/certbot
        ports:
            - 80:80
            - 443:443

    certbot:
        image: certbot/certbot:latest
        command: certonly --webroot --webroot-path=/var/www/certbot --email [email protected] --agree-tos --no-eff-email -d domain.com -d www.domain.com
        volumes:
            - ./certbot/conf:/etc/letsencrypt
            - ./certbot/logs:/var/log/letsencrypt
            - ./certbot/data:/var/www/certbot

Hit CTRL-X followed by Y and ENTER to save and exit the file.

Here are the configuration details.

  • version: Compose file version which is compatible with the Docker Engine. You can check compatibility here.
  • image: We use latest Nginx and Certbot images available in Docker hub.
  • volumes:
    • public: we have configured this directory to be synced with the directory we wish to use as the web root inside the container.
    • conf.d: here we will place the Nginx configuration file to be synced with the default Nginx conf.d folder inside the container.
    • certbot/conf: this is where we will receive the SSL certificate and this will be synced with the folder we wish to inside the container.
    • ports: configure the container to listen upon the listed ports.
    • command: the command used to receive the SSL certificate.

Now you have your docker-compose.yml in place.

Configure Nginx

Now we need to configure Nginx for validation to obtain the Let’s Encrypt SSL certificate.

We will create a directory as mentioned in the docker-compose file as conf.d.

sudo mkdir ~/nginx-ssl/conf.d

Create a configuration file with the .conf extension.

sudo nano ~/nginx-ssl/conf.d/default.conf

Paste the following configuration inside the file.

 server {
     listen [::]:80;
     listen 80;

     server_name domain.com www.domain.com;

     location ~ /.well-known/acme-challenge {
         allow all; 
         root /var/www/certbot;
     }
} 

Hit CTRL-X followed by Y and ENTER to save and exit the file.

Now you have the Nginx configuration which gets synced to the /etc/nginx/conf.d folder which automatically gets loaded by Nginx.

Start Containers

Now it’s time to start the containers using the following command to receive the SSL certificates.

You need to pass the -d flag which starts the container in background and leaves them running.

docker-compose up -d

You will see an output similar to the one below.

Output
Creating network "nginx-ssl_default" with the default driver
Pulling web (nginx:latest)…
latest: Pulling from library/nginx
8559a31e96f4: Pull complete
8d69e59170f7: Pull complete
3f9f1ec1d262: Pull complete
d1f5ff4f210d: Pull complete
1e22bfa8652e: Pull complete
Digest: sha256:21f32f6c08406306d822a0e6e8b7dc81f53f336570e852e25fbe1e3e3d0d0133
Status: Downloaded newer image for nginx:latest
Pulling certbot (certbot/certbot:latest)…
latest: Pulling from certbot/certbot
cbdbe7a5bc2a: Pull complete
26ebcd19a4e3: Pull complete
a29d43ca1bb4: Pull complete
979dbbcf63e0: Pull complete
30beed04940c: Pull complete
48a1f8a4d505: Pull complete
4416e9b4bbe0: Pull complete
8173b4be7870: Pull complete
21c8dd124dab: Pull complete
c19b04e11dc7: Pull complete
1b560611cec1: Pull complete
Digest: sha256:568b8ebd95641a365a433da4437460e69fb279f6c9a159321988d413c6cde0ba
Status: Downloaded newer image for certbot/certbot:latest
Creating nginx-ssl_certbot_1 … done
Creating nginx-ssl_web_1     … done

This output indicates Nginx and Certbot images are pulled from Docker hub and the containers are created successfully.

To view the containers you can execute the following command.

docker-compose ps
Output
       Name                      Command               State                     Ports
nginx-ssl_certbot_1   certbot certonly --webroot …   Exit 0                                           
nginx-ssl_web_1       /docker-entrypoint.sh ngin …   Up       0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp

The state Exit 0 indicates the setup is completed without any error.

Now when you check your work directory, there will be a new directory created as certbot inside which you will have the SSL certificate synced.

ls ~/nginx-ssl/certbot/conf/live/domain.com

Configure SSL with Nginx

As you have received the Let’s Encrypt SSL certificate you can configure HTTPS and setup redirection to HTTPS.

Edit the default.conf and make the following changes.

Your file should like the one below at the final stage.

server {
    listen [::]:80;
    listen 80;

    server_name domain.com www.domain.com;

    location ~ /.well-known/acme-challenge {
        allow all; 
        root /var/www/certbot;
    }

    # redirect http to https www
    return 301 https://www.domain.com$request_uri;
}

server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;

    server_name domain.com;

    # SSL code
    ssl_certificate /etc/nginx/ssl/live/domain.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/live/domain.com/privkey.pem;

    root /var/www/html;

    location / {
        index index.html;
    }

    return 301 https://www.domain.com$request_uri;
}

server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;

    server_name www.domain.com;

    # SSL code
    ssl_certificate /etc/nginx/ssl/live/domain.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/live/domain.com/privkey.pem;

    root /var/www/html/domain-name/public;

    location / {
        index index.html;
    }
} 

Hit CTRL-X followed by Y and ENTER to save and exit the file.

Create index.html file

Now you can create the index.html file inside the public directory which then syncs to the directory configured.

Create the public directory.

sudo mkdir ~/nginx-ssl/public
sudo nano ~/nginx-ssl/public/index.html
<html>
    <body>
        <h1>Docker setup with Nginx and Let's Encrypt SSL.</h1>
    </body>
</html

Hit CTRL-X followed by Y and ENTER to save and exit the file.

Restart the containers

Now you can restart the containers to load the new configurations.

docker-compose restart

Once the containers are restarted you can check your domain name. You will get a redirection to HTTPS and your SSL.

Get your Professional Google Cloud Architect certificate with this easy to learn course now.

Conclusion

Now you have learned how to install and configure Nginx and Let’s Encrypt with Docker on Ubuntu 20.04.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

How to Setup Elasticsearch cluster with Multiple Nodes

Prev Post

Since this post shares cloud strategies with awesome people like you, naturally this post may contain affiliate links for products I use and love. If you click on those links and make a purchase, I’ll earn some coffee money which I drink while creating more helpful content like this.

Install WordPress with Docker Nginx Reverse Proxy to Apache with SSL - Google Cloud

Next Post

Since this post shares cloud strategies with awesome people like you, naturally this post may contain affiliate links for products I use and love. If you click on those links and make a purchase, I’ll earn some coffee money which I drink while creating more helpful content like this.

Nginx и php-fpm не получается связать в docker

В целях изучения Docker взялся за связку php и nginx. Связать их вместе не получилось.

Моя последовательность действий:

Запускаю контейнер с php первым (т.к nginx его потом использует):

Создаю Dockerfile для nginx:

Собираю образ с Nginx:

Перехожу на 0.0.0.0:80 и браузер выводит File not found. В логах контейнера nginx:

В команде запуска контейнера с php надо указать открытый порт.

Уже пробовал

Вообще nginx видит контейнер php без проброса порта php наружу.

Все перезапустил. Результат тот же. Может я накосячил default.host?

Что говорит curl на 9000 порт php контейнера из контейнера Nginx’а ?

А curl что пишет?)

curl: (56) Recv failure: Connection reset by peer

А у тебя точно, твой порт контейнера проброшен во внешний мир и слушает твой 172.17.0.2 , а не 127.0.0.1 ?

172.17.0.0/16, по-моему, внутреняя дефолтная сеть докера

Похоже, что в принципе порт пыхи видно. Но почему-то nginx до контейнера достучаться не может.
попробуй:

  1. в браузере не 0.0.0.0, а localhost (порт 80 можно не писать, браузер его автоматом добавляет)
  2. на всякий случай добавь сеть при запуске контейнеров: https://docs.docker.com/network/bridge/
  3. в конфиг default.conf после listen 80 добавь: server_name localhost;
  4. тут так: sudo docker run -d –name php_container php
  5. тома проще папками подключать, чем файлами: -v /home/yr:/var/www/html

А вообще лучше docker-compose попробуй, то же самое, только не возиться в консоли, а в файле всё это пишешь и роняешь-поднимаешь пока не поймешь суть

Источник

10-listen-on-ipv6-by-default.sh: error: /etc/nginx/conf.d/default.conf is not a file or does not exist #461

Comments

davStar commented Oct 17, 2020 •

Hello dear team,

I ve updated my container and I stuck.
However my conf files are well mounted but it asks a default.conf files that it never ask before.

Configuration:

NGINX alpine official image
HOST : UBUNTU 20.0.4
Docker version 19.03.8, build afacb8b7f0

Issue Description:
I encounter an issue at the start of the container:

When I rename beta-rp.conf by default.conf I encounter the following message:

==> error: /etc/nginx/conf.d/default.conf differs from the packages version

Configuration:

Here is my conf file named beta-rp.conf:

«^(docker/1.(3|4|5(?!.[0-9]-dev))|Go ).*$» ) < return 404; >proxy_pass http://account_manager_service/api/v0.1/account_manager/authentification/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 900; > location /api/v0.1/account_manager/register/ < # Do not allow connections from docker 1.5 and earlier # docker pre-1.6.0 did not properly set the user agent on ping, catch «Go *» user agen>if ($http_user_agent

«^(docker/1.(3|4|5(?!.[0-9]-dev))|Go ).*$» ) < return 404; >proxy_pass http://account_manager_service/api/v0.1/account_manager/register/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 900; > > «>

I use Ansible playbook and docker_container module where I mount my conf file:

My path /opt/devops/nginx/ contains conf.d and ssl folders where I can see my conf files.

When I user docker exec -it nginx bash, I can see my beta-rp.conf files and my ssl files in the respectives folders.

Please need your support.

The text was updated successfully, but these errors were encountered:

Источник

Как исправить ошибку nginx на сервере?

Добрый день.
Возникла проблема на рабочем сервере.
Создал образ docker на локальном, выгрузил на сервер.
Естественно сайт не запустился.
В логах docker на сервере ошибка

docker logs cont-nginx_1
/docker-entrypoint.sh: Configuration complete; ready for start up
2020/12/28 13:38:57 [emerg] 1#1: open() «/etc/nginx/fastcgi-params» failed (2: No such file or directory) in /etc/nginx/conf.d/default.conf:26
nginx: [emerg] open() «/etc/nginx/fastcgi-params» failed (2: No such file or directory) in /etc/nginx/conf.d/default.conf:26

Если посмотреть логи docker на локальном, то никакой ошибки нет и всё работает.

docker logs cont-nginx_1
/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: /etc/nginx/conf.d/default.conf differs from the packaged version
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Configuration complete; ready for start up

Образ собирался из

Куда пропал fastcgi-params? Как исправить ситуацию?

Источник

/etc/nginx/conf.d/default.conf differs from the packaged version, exiting #419

Comments

matuszewskijan commented Jun 3, 2020 •

Hello, I am trying to setup Rails application with ngnix, but no matter what I do I am always getting this error: nginx_1 | 10-listen-on-ipv6-by-default.sh: /etc/nginx/conf.d/default.conf differs from the packaged version, exiting when using: sudo docker-compose -f docker-compose.prod.yml up command any similar.

Anyone is having any idea why it happen? I’ve tried everything what comes to my mind to fix it. I wonder how the Conffiles are generated as it seems to be the source of the issue: https://github.com/nginxinc/docker-nginx/blob/master/mainline/alpine/10-listen-on-ipv6-by-default.sh

The text was updated successfully, but these errors were encountered:

thresheek commented Jun 3, 2020

That means the 10-listen-on-ipv6-by-default.sh exits, not the container itself. I guess I should update the wording to avoid confusion.

willzhang commented Jul 29, 2020

That means the 10-listen-on-ipv6-by-default.sh exits, not the container itself. I guess I should update the wording to avoid confusion.

i don’t like the error

thresheek commented Jul 29, 2020

That’s normal when you have default.conf differing from what we package. We delibarately would not change it to enable ipv6. (in your case, its already enabled). You can suppress error messages with NGINX_ENTRYPOINT_QUIET_LOGS variable in your docker container environment configuration.

mahrton commented Jul 31, 2020

@thresheek sorry just an opinion, because I do not know if you have a policy governing these things, but then it is not really an error. it is just an «info». I also ran into this and when I saw the word «error» I automatically thought I have made a mistake in the configuration.

shijiezhou03 commented Aug 21, 2020

I dont like when it say the error on this case.

davStar commented Oct 18, 2020

I ve raised an issue related to this issue here. I m lost. connection between the host and my backend working like a charmed.

My conf file was working before I ve redeployed my Nginx container.
The conf file is well pointed (checked via docker exec)

When I change the name from default.conf to xxx.conf (before named xxx.conf , and suddenly error as no default.conf was located. )

The message is the following:

However the service seems not running and not lin with my backend anymore.

Needs your support please!

panique commented Oct 18, 2020

I found the error in my case ! My non working nginx config had this line:

and the problem was that php seems to a hostname here, but nginx box couldnt find another docker box reachable with the name php .

But this works: Rename the PHP docker box to something different like

and change the nginx config accordingly

danielecr commented Oct 22, 2020

I am experiencing the same problem in a service run as docker swarm ( docker stack deploy )
the error was «No route to host», after surfing and searching I found that nginx service was ready before the companion service (php fpm), I just stopped the container and the swarm controller restart a new one, this fixed the problem.
I have no idea on how to solve this (there is a solution in docker.com site, actually), but I think it is not correct this upfront resolution of ip address in a docker environment.

I mean, why nginx resolve address name once at start and not ask for resolver every time? If I had removed the service then deployed it again that would have not worked, because the nginx resolved with the old service address that changes everytime a service is restarted.

(my case is fastcgi_pass ), the author say «Nginx evaluates the value of the variable per-request, instead of just once at startup.», and it is workaround way

Источник

Error in nginx config with Docker #701

Comments

1ubuntuuser commented Mar 15, 2022

Recently found this project, excited to give it a try for a NFP I am working on. 🙂

Description of the issue

There seems to be an error with the current nginx config when deploying on production according to the documentation. I’m pretty experienced with docker so I don’t think I’m doing anything dumb.

Context information (for bug reports)

Latest version of docker and docker-compose running on ubunu.

Steps to reproduce the issue

  1. Download repo with git
    2. docker-compose -f compose.yaml -f overrides/compose.erpnext.yaml -f overrides/compose.mariadb.yaml -f overrides/compose.redis.yaml -f overrides/compose.https.yaml config >

/app/erpnext/docker-compose.yml
docker-compose —project-name xx -f

nginx.conf as extracted from container

Stacktrace / full error message if available

The text was updated successfully, but these errors were encountered:

revant commented Mar 15, 2022

there are certain mandatory variables needed for the image

Lines 41 to 47 in 0906034

# For refactored images
— BACKEND=erpnext-python:8000
— SOCKETIO=frappe-socketio:9000
— FRAPPE_SITE_NAME_HEADER=$
— UPSTREAM_REAL_IP_ADDRESS=$
— UPSTREAM_REAL_IP_HEADER=$
— UPSTREAM_REAL_IP_RECURSIVE=$

defnotjonas commented Mar 15, 2022 •

This worked for me

I was just facing the same issue. I found an error in my docker-compose.yaml file.

I resolved the issue by changing $$$$host to $$host .

Steps to reproduce

The parent directory that the docker-compose.yaml is written to, is empty except for the frappe_docker git repository.
Running docker-compose up -d results in the same error as above.

Probable cause of the error

There seems to be an issue with the way, that the way that the final docker-compose.yaml is combined. Running docker-compose -f compose.yaml config > ../docker-compose.yaml produces the same $$$$ -problem.

revant commented Mar 15, 2022

There seems to be an issue with the way, that the way that the final docker-compose.yaml is combined.

thanks for the help in figuring it out. I’ll check what can be done to fix.

1ubuntuuser commented Mar 16, 2022

This worked for me

I was just facing the same issue. I found an error in my docker-compose.yaml file.

I resolved the issue by changing $$$$host to $$host .

Steps to reproduce

The parent directory that the docker-compose.yaml is written to, is empty except for the frappe_docker git repository. Running docker-compose up -d results in the same error as above.

Probable cause of the error

There seems to be an issue with the way, that the way that the final docker-compose.yaml is combined. Running docker-compose -f compose.yaml config > ../docker-compose.yaml produces the same $$$$ -problem.

Removing the extra $$ fixed it for me too! Thanks. I did notice the extra $$. I thought it as some fancy var passing method or somthing.

vrslev commented Mar 16, 2022

The issue comes up if you use docker-compose v1. On second version everything works fine. There’s no universal solution: v1 requires «$host», v2 — «$$host».

1ubuntuuser commented Mar 17, 2022

The issue comes up if you use docker-compose v1. On second version everything works fine. There’s no universal solution: v1 requires «$host», v2 — «$$host».

Actaully, the text in the compose yml defults to «$$$$host» not «$$host». The 4 dollar signs is what is causing the issue.

defnotjonas commented Mar 18, 2022 •

@1ubuntuuser I think you misunderstood. @vrslev is correct in their answer. Let me elaborate:

compose.yaml contains the following:

Notice the $$host.

with Compose v1

I ran into problems using docker-compose v1 ( docker-compose -v : docker-compose version 1.29.2, build 5becea4c). The command docker-compose -f compose.yaml parses the line to

So we would need a single $ in compose.yaml.

with Compose v2

After upgrading to docker-compose v2 ( docker-compose -v : Docker Compose version v2.2.3), the same command parses the line to

Источник

Контекст

У меня было приложение, работающее с глобальным Nginx в качестве обратного прокси на моем частном сервере без проблем. Однако для моего проекта мне нужно развернуть его на серверах моего университета, где мне нужно будет переместить все это в мои контейнеры, но я не могу заставить его работать.

Общая настройка проекта

Краткое введение в настройку: у меня есть интерфейс frontend-ui, который представляет собой простой PWA, созданный с помощью vue, который также использует Firebase Messaging для уведомлений. Токены уведомлений хранятся в моем диспетчере уведомлений — приложении Spring — в базе данных, и он также выполняет все запросы к базе данных, такие как удаление токенов при удалении и т. д. Мой третий пользовательский интерфейс — это интерфейс-уведомление, который предоставляет простой (vue) интерфейс для отправки out уведомления с помощью firebase, для этого он также взаимодействует с базой данных для получения токенов. Все проекты находятся в одной папке с docker-compose.
Мне нужны оба моих фронта для обслуживания https.

Настройка Nginx / Docker

Интерфейс-интерфейс

Мой интерфейс-интерфейс имеет следующую конфигурацию Nginx, а сертификаты находятся в папке сертификатов:

server {
  listen 80;
  server_name SERVERNAME;
  # Redirect all traffic to SSL
  rewrite ^ https://$server_name$request_uri? permanent;
}

server {
  listen 443 ssl;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_prefer_server_ciphers on;
  ssl_ciphers "EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA256:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EDH+aRSA+AESGCM:EDH+aRSA+SHA256:EDH+aRSA:EECDH:!aNULL:!eNULL:!MEDIUM:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED";

  add_header Strict-Transport-Security "max-age=31536000";
  server_name SERVERNAME;

  ## Access and error logs.
  access_log /var/log/nginx/access.log;
  error_log  /var/log/nginx/error.log info;

  ## Server certificate and key.
  ssl on;
    ssl_certificate /etc/nginx/ssl/nginx.cert;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;

  root /usr/share/nginx/html;
  location / {
    try_files $uri $uri/ =404;
  }
  location /api {
    proxy_pass http://127.0.0.1:42372;
  }
}

И этот Dockerfile:

# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json /app/
RUN npm install
COPY . .
RUN npm run build

#COPY default.conf /etc/nginx/conf.d/
#COPY certificates/nginx.cert /etc/ssl/
#COPY certificates/nginx.key /etc/ssl/

# production stage
FROM nginx:stable-alpine as production-stage

COPY certificates/nginx.cert /etc/nginx/ssl/
COPY certificates/nginx.key /etc/nginx/ssl/

COPY default.conf /etc/nginx/conf.d/

COPY --from=build-stage /app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]

Уведомление-пользовательский интерфейс

Мой интерфейс-уведомление имеет следующую конфигурацию Nginx, а сертификаты находятся в папке Certificates:

server {
  listen 80;
  server_name SERVERNAME;
  # Redirect all traffic to SSL
  rewrite ^ https://$server_name$request_uri? permanent;
}

server {
  listen 443 ssl;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_prefer_server_ciphers on;
  ssl_ciphers "EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA256:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EDH+aRSA+AESGCM:EDH+aRSA+SHA256:EDH+aRSA:EECDH:!aNULL:!eNULL:!MEDIUM:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED";

  add_header Strict-Transport-Security "max-age=31536000";
  server_name SERVERNAME;

  ## Access and error logs.
  access_log /var/log/nginx/access.log;
  error_log  /var/log/nginx/error.log info;

  ## Server certificate and key.
  ssl on;
    ssl_certificate /etc/nginx/ssl/nginx.cert;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;

  root /usr/share/nginx/html;
  location / {
    try_files $uri $uri/ =404;
  }
  location /api {
    proxy_pass http://127.0.0.1:42372;
  }
}

И этот Dockerfile:

# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json /app/
RUN npm install
COPY . .
RUN npm run build

#COPY default.conf /etc/nginx/conf.d/
#COPY certificates/nginx.cert /etc/ssl/
#COPY certificates/nginx.key /etc/ssl/

# production stage
FROM nginx:stable-alpine as production-stage

COPY certificates/nginx.cert /etc/nginx/ssl/
COPY certificates/nginx.key /etc/nginx/ssl/

COPY default.conf /etc/nginx/conf.d/

COPY --from=build-stage /app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]

Уведомление-бэкэнд

У моего бэкэнда нет конфигурации Nginx, так как она сама по себе не нужна. Dockerfile выглядит так:

### BUILDER
FROM maven:3.6.3-jdk-11-slim as builder

RUN mkdir -p /build
WORKDIR /build
COPY pom.xml /build

#Download dependencies
#RUN mvn -B dependency:resolve dependency:resolve-plugins

#copy src-code
COPY src /build/src

#Build application
RUN mvn clean install

### RUNTIME

FROM openjdk:11-slim as runtime
ENV APP_HOME /

#Create folders for config and logging
RUN mkdir $APP_HOME/config
RUN mkdir $APP_HOME/log

VOLUME $APP_HOME/log
VOLUME $APP_HOME/config

WORKDIR $APP_HOME
#Copy jar from builder
COPY --from=builder /build/target/*.jar notificationmanager.jar
ENTRYPOINT ["java","-jar","notificationmanager.jar", "de.hsa.frontend.notificationmanager.NotificationmanagerApplication"]

Развертывание

Я развертываю сеть с помощью docker-compose:

version: '3.2'
services:
    backend:
        image: notificationmanager-be:1
        build:
            context: ./notificationmanager
            dockerfile: ./Dockerfile
        ports:
            - "42372:8085"
        networks:
            - notificationmanager
        restart: on-failure:5
    notification-ui:
        image: notificationmanager-ui:1
        build:
            context: ./notificationmanager-ui
            dockerfile: ./Dockerfile
        ports:
            - "42373:80"
            - "42376:443"
        networks:
            - notificationmanager
    db:
        image: postgres
        ports:
            - "42374:5432"
        environment:
            - POSTGRES_USER=USERNAME
            - POSTGRES_PASSWORD=PASSWORD
            - POSTGRES_DB=DATABASE
        volumes:
            - data:/var/lib/postgresql/data/
        restart: on-failure:5
    frontend-ui:
        image: frontend-ui:1
        build:
            context: ./frontend-ui
            dockerfile: ./Dockerfile
        ports:
            - "42375:80"
            - "42377:443"
        networks:
            - notificationmanager
networks:
    notificationmanager:
        driver: bridge
volumes:
    data:
        driver: local

Отображение порта 443 я добавил в качестве последней идеи о том, почему он может не работать, поэтому я могу его снова удалить. Я не вижу большой разницы от просмотренных мною онлайн-туториалов, но я все равно получаю SSL-ошибку (ERR_SSL_PROTOCOL_ERROR) при попытке открыть веб-страницы, Dev-Tools не показывает никаких ошибок, журналы из внешнего интерфейса -ui выглядят так (другие похожи):

/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: info: /etc/nginx/conf.d/default.conf differs from the packaged version


/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh


/docker-entrypoint.sh: Configuration complete; ready for start up


2021/03/29 11:55:04 [warn] 1#1: the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/conf.d/default.conf:23


nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/conf.d/default.conf:23


10.144.43.100 - - [29/Mar/2021:11:55:53 +0000] "x16x03x01x02x00x01x00x01xFCx03x03xB1xC7" 400 157 "-" "-" "-"


10.144.43.100 - - [29/Mar/2021:11:55:53 +0000] "x16x03x01x02x00x01x00x01xFCx03x03:XxFBx83xADx18x13n^xF4x06:xEDx93~;xB2%jxD0xACxDCxFB#WxCB)bx16rxC9xCE xFEx1FuxA3Y;xB2xC0xFBx11 x02xDEx91=$U" 400 157 "-" "-" "-"


10.144.43.100 - - [29/Mar/2021:11:55:54 +0000] "x16x03x01x02x00x01x00x01xFCx03x03Bpx91xA8xC6h)x81xA41x12xAAlxF4xD1qxA8xEAxC6{xC4x0Bx83xA9xE1xFCJ@1#x1FxB9 ?xCFVxA7x0Fvxx1CxF5xF5xA4x0BxAFxA2Z>xB4xCAxC4!i;F6xC0x1FxB5Hx94xC4xBCx19x00x22::x13x01x13x02x13x03xC0+xC0/xC0,xC00xCCxA9xCCxA8xC0x13xC0x14x00x9Cx00x9Dx00/x005x00" 400 157 "-" "-" "-"


10.144.43.100 - - [29/Mar/2021:11:55:54 +0000] "x16x03x01x02x00x01x00x01xFCx03x03x9D#Ju;j24xC0xF6xEAxDCxBFxFAx0E;xBDJx030xD4xF6xE8Vx88IxB8/'xA6Vj xA1Bx17x5C$" 400 157 "-" "-" "-"

Я немного переименовал, чтобы улучшить читаемость, и попытался удалить все свои (неудачные) попытки решения возможных проблем, поэтому прошу прощения, если где-то это не удалось. Мне пришлось удалить некоторые значения (например, данные для входа в базу данных), поэтому я просто написал туда заполнители, файлы, конечно, заполнены полностью.
Может ли кто-нибудь указать мне на мою ошибку?

m-picc

Describe the bug

The nginxinc/nginx-unprivileged:alpine-slim image fails to startup on a arm64 based OS while the nginxinc/nginx-unprivileged:latest image runs successfully

To reproduce

Steps to reproduce the behavior:

  1. On an arm64 based device, run docker run -it nginxinc/nginx-unprivileged:alpine-slim
  2. the following output occurs:
/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: can not modify /etc/nginx/conf.d/default.conf (read-only file system?)
/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
2022/12/28 17:34:38 [emerg] 1#1: mkdir() "/tmp/proxy_temp" failed (13: Permission denied)
nginx: [emerg] mkdir() "/tmp/proxy_temp" failed (13: Permission denied)

Expected behavior

I expected the nginx process to startup successfully just as the normal nginxinc/nginx-unprivileged:latest image does on an arm64 based device.

Your environment

  • Version of Docker: Docker version v19.03.15-ce, build 99e3ed8919
  • Version of the NGINX Unprivileged Docker image: nginxinc/nginx-unprivileged:alpine-slim
  • Target deployment environment/platform: arm64

eerotki

I’m using nginxinc/nginx-unprivileged:alpine in Docker to run Nginx non-root. During the build in Dockerfile, I restrict /etc/nginx folder to read & execute permissions only with chmod 555 -R /etc/nginx, so that no running config could be altered. Due to changes after 1.17.10 I’m experiencing unexpected behavior, where the build fails on start up with message:

/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: Can not modify /etc/nginx/conf.d/default.conf (read-only file system?), exiting
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-configure-nginx-unprivileged.sh
sed: can't create temp file '/etc/nginx/conf.d/default.confXXXXXX': Permission denied

If I grant write permissions on /etc/nginx/conf.d the build will fail with message:

sed: can't create temp file '/etc/nginx/nginx.confXXXXXX': Permission denied

So I assume Nginx now requires write permissions on /etc/nginx. Is this behaviour intentional and expected?

I would like to retain my setup and deny write permissions on config folders.

mkesper

sfgroups-k8s

romh87

Is your feature request related to a problem? Please describe

Latest openssl vulnerabilities solved in version 3.0.7

Describe the solution you’d like

openssl 3.0.7 published yesterday, is already available in apk, please republish the dockerhub images so that we have the latest safest version

CoreMoni

As we always want to use the newest versions of the tools we are using we used the feature of GitHub to watch new Releases.

Going to Watch —> Custom —> Check the checkbox of Releases —> Apply

This GitHub feature will only work if there are any Relaseses. Is it many also possible for nginx to create GitHub Releases in the future.
This will help us and I hope more companies very much.

cableman

Is your feature request related to a problem? Please describe

Have you considered signing the release tags, so people using DOCKER_CONTENT_TRUST=1 can use these images. The official nginx image are signed with DCT.

For more about DCT see https://docs.docker.com/engine/security/trust/

Describe the solution you’d like

That the images are signed like the official nginx images :-).

See docker trust inspect --pretty nginx:alpine

Describe alternatives you’ve considered

Build own images base on these images and sign them, but that somehow seams wrong.

alesbrelih

Describe the bug

I’ve noticed that image tags were overwritten in last few days/hours from the main branch content. This broke our configuration due to the docker user change from UID to nginx.

Docker history of the new tag that got overwritten:

docker history docker.io/nginxinc/nginx-unprivileged:1.23.2-alpine-slim
IMAGE          CREATED       CREATED BY                                      SIZE      COMMENT
e38f12a31b95   6 hours ago   CMD ["nginx" "-g" "daemon off;"]                0B        buildkit.dockerfile.v0
<missing>      6 hours ago   USER nginx                                      0B        buildkit.dockerfile.v0
<missing>      6 hours ago   STOPSIGNAL SIGQUIT                              0B        buildkit.dockerfile.v0
<missing>      6 hours ago   EXPOSE map[8080/tcp:{}]                         0B        buildkit.dockerfile.v0
<missing>      6 hours ago   ENTRYPOINT ["/docker-entrypoint.sh"]            0B        buildkit.dockerfile.v0
<missing>      6 hours ago   COPY 30-tune-worker-processes.sh /docker-ent…   4.62kB    buildkit.dockerfile.v0
<missing>      6 hours ago   COPY 20-envsubst-on-templates.sh /docker-ent…   1.26kB    buildkit.dockerfile.v0
<missing>      6 hours ago   COPY 10-listen-on-ipv6-by-default.sh /docker…   2.13kB    buildkit.dockerfile.v0
<missing>      6 hours ago   COPY docker-entrypoint.sh / # buildkit          1.62kB    buildkit.dockerfile.v0
<missing>      6 hours ago   RUN |2 UID=101 GID=101 /bin/sh -c sed -i 's,…   10.7kB    buildkit.dockerfile.v0
<missing>      6 hours ago   RUN |2 UID=101 GID=101 /bin/sh -c set -x    …   4.56MB    buildkit.dockerfile.v0
<missing>      6 hours ago   ARG GID=101                                     0B        buildkit.dockerfile.v0
<missing>      6 hours ago   ARG UID=101                                     0B        buildkit.dockerfile.v0
<missing>      6 hours ago   ENV PKG_RELEASE=1                               0B        buildkit.dockerfile.v0
<missing>      6 hours ago   ENV NGINX_VERSION=1.23.2                        0B        buildkit.dockerfile.v0
<missing>      6 hours ago   LABEL maintainer=NGINX Docker Maintainers <d…   0B        buildkit.dockerfile.v0
<missing>      3 weeks ago   /bin/sh -c #(nop)  CMD ["/bin/sh"]              0B        
<missing>      3 weeks ago   /bin/sh -c #(nop) ADD file:685b5edadf1d5bf0a…   7.46MB

To reproduce

Pull docker image using:

docker pull nginxinc/nginx-unprivileged:1.23.2-alpine-slim

Inspect content:

docker history docker.io/nginxinc/nginx-unprivileged:1.23.2-alpine-slim

Expected behavior

Dockerfile content should match to the one of the 1.23.2 tag.

Your environment

docker --version
Docker version 20.10.21, build baeda1f

chidaran-aetna

Describe the bug

Twistlock scan 2 critical vulnerabilities and 1 high vulnerability for the image : nginxinc/nginx-unprivileged

CVE | SEVERITY | CVSS | PACKAGE | VERSION | STATUS | PUBLISHED | DISCOVERED | DESCRIPTION | TRIGGERED FAILURE |
+—————-+———-+——+—————+————————-+———+————+————+—————————————————-+——————-+
| CVE-2022-3970 | critical | 9.80 | tiff | 4.2.0-1+deb11u1 | open | 38 days | < 1 hour | A vulnerability was found in LibTIFF. It has | Yes |
| | | | | | | | | been classified as critical. This affects | |
| | | | | | | | | the function TIFFReadRGBATileExt of the file | |
| | | | | | | | | libtiff/tif_getima… | |
+—————-+———-+——+—————+————————-+———+————+————+—————————————————-+——————-+
| CVE-2022-32221 | critical | 9.80 | curl | 7.74.0-1.3+deb11u3 | open | 16 days | < 1 hour | When doing HTTP(S) transfers, libcurl | Yes |
| | | | | | | | | might erroneously use the read callback | |
| | | | | | | | | (CURLOPT_READFUNCTION) to ask for data to send, | |
| | | | | | | | | even when the `CURLOPT… | |
+—————-+———-+——+—————+————————-+———+————+————+—————————————————-+——————-+
| CVE-2022-42916 | high | 7.50 | curl | 7.74.0-1.3+deb11u3 | open | 53 days | < 1 hour | In curl before 7.86.0, the HSTS check could be | No |
| | | | | | | | | bypassed to trick it into staying with HTTP. Using | |
| | | | | | | | | its HSTS support, curl can be instructed to use | |
| | | | | | | | | HTTP… | |
+—————-+———-+——+—————+—

To reproduce

Steps to reproduce the behavior:

  1. Deploy NGINX Unprivileged Docker image
  2. View output/logs/configuration on CircleCI with Twistlock scan enabled
  3. See error

Your environment

  • Version of the NGINX Unprivileged Docker image
  • Target deployment environment/platform

Additional context

Does this security vulnerability relate to one of the NGINX libraries specified in the SECURITY doc?

ovideo

Describe the bug

Trivy container scan reports CVE-2022-3996 vulnerability for libcrypto3 and libssl3 libraries with High severity

To reproduce

Steps to reproduce the behavior:
Run Trivy scan on nginxinc/nginx-unprivileged:1.23-alpine container

Your environment

  • Version of the NGINX Unprivileged Docker image : 1.23-alpine
  • Target deployment environment/platform

Additional context

Does this security vulnerability relate to one of the NGINX libraries specified in the SECURITY doc?
YES

enrico9034

Hi, I test today image tags 1.23.2 and 1.23.3. From this version, I see all containers run with user root.
Please can you roll back the changes?

bateleurX

Is your feature request related to a problem? Please describe

There are pull rate limitations in Docker Hub. If this image is registered to alternative public registries(GitHub Container Registry, AWS ECR Public,,,,), we can use them to avoid limitations and may reduce network latency.

Describe the solution you’d like

publishing images to ECR Public, GitHub Container Registry

Describe alternatives you’ve considered

Additional context

publishing in GHCR is not a complicated method. Here is my experimental implementation pushing to GHCR.
https://github.com/bateleurX/docker-nginx-unprivileged/compare/main..ghcr

karlskewes

Any chance we can please build & push images for other architectures like here?:
nginxinc/docker-nginx#290

arm64:

$ uname -a
Linux k8s-m-01 4.4.154-1128-rockchip-ayufan-g61b4b1151f9a #1 SMP Tue Dec 25 14:31:31 UTC 2018 aarch64 aarch64 aarch64 GNU/Linux

docker run:

$ sudo docker run nginxinc/nginx-unprivileged:alpine
Unable to find image 'nginxinc/nginx-unprivileged:alpine' locally
alpine: Pulling from nginxinc/nginx-unprivileged
4fe2ade4980c: Pull complete 
9eb6510d469d: Pull complete 
53a04bd986f3: Pull complete 
530e67dc0e9c: Pull complete 
c3d9ca62b5b0: Pull complete 
Digest: sha256:de550f18ba38c832034fa4f2fe1ecd2ee370593f7a523ae0825159626098be44
Status: Downloaded newer image for nginxinc/nginx-unprivileged:alpine
standard_init_linux.go:190: exec user process caused "exec format error"

docker manifest inspect (no arch listed?):

$ DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect nginxinc/nginx-unprivileged:alpine
{
	"schemaVersion": 2,
	"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
	"config": {
		"mediaType": "application/vnd.docker.container.image.v1+json",
		"size": 8712,
		"digest": "sha256:2c9ea44d06942609980c7f088f20ff41a702bb6fafa023ced02752ea472aa00b"
	},
	"layers": [
		{
			"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
			"size": 2206931,
			"digest": "sha256:4fe2ade4980c2dda4fc95858ebb981489baec8c1e4bd282ab1c3560be8ff9bde"
		},
		{
			"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
			"size": 5535768,
			"digest": "sha256:9eb6510d469dbc7c82205604f6008ded76563dd9d55f3a4d188792ae915d8794"
		},
		{
			"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
			"size": 545,
			"digest": "sha256:53a04bd986f3d2bfb38cbea618420a6f8481d7b491c0ff7fcf9b9136554d9fac"
		},
		{
			"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
			"size": 636,
			"digest": "sha256:530e67dc0e9c09a21619c99142594f54e199ef2a93fd5f1a5a0523115ffbf49c"
		},
		{
			"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
			"size": 148,
			"digest": "sha256:c3d9ca62b5b099324ef9eab8581927805f2836c6a6724f3cf5910c5213314cbc"
		}
	]
}

dcshiman

Describe the bug

I am trying to enable IPv6 on the container, but when the container starts up it give me the following message even though I am using the default /etc/nginx/conf.d/default.conf file.

10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version

To reproduce

Steps to reproduce the behavior:

  1. Deploy NGINX Unprivileged Docker image nginxinc/nginx-unprivileged:1.22.1
  2. View output/logs/configuration on ’10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version’
  3. See error

Expected behavior

IPv6 should be enabled by changing port to listen [::]:8080

Your environment

  • Version of Docker: Using AWS Bottlerocket AMI on AWS EKS kubernetes v1.23 on IPv6
  • Version of the NGINX Unprivileged Docker image nginxinc/nginx-unprivileged:1.22.1
  • Target deployment kubernetes

Additional context

I would am using the container with kuberhealthy test run. Which dose not allow to change the entrypoint of the container. It would be helpful if we can turn on IPv6 by Environment variable NGINX_PORT

satheesh19081987

Describe the bug

We are getting 4 CRITICAL vulnerabilities in Harbor image scan . please update the libraries .
image

To reproduce

Steps to reproduce the behavior:

  1. Deploy NGINX Unprivileged Docker image
  2. View output/logs/configuration on ‘…’
  3. See error

Your environment

  • Version of the NGINX Unprivileged Docker image
  • Target deployment environment/platform

Additional context

Does this security vulnerability relate to one of the NGINX libraries specified in the SECURITY doc?

jar349

Describe the bug

This commit 18 days ago introduced a capability to source *.envsh files that are found inside /docker-entrypoint.d which I have taken advantage of.

Having done so, docker-entrypoint.sh now crashes: /docker-entrypoint.sh: 21: 3: Bad file descriptor. I do not see in the script where file descriptor 3 is assigned. I believe that this is probably a copy/paste error where echo >&3 should be replaced with entrypoint_log

To reproduce

Steps to reproduce the behavior:

  1. Extend the NGINX Unprivileged Docker image with your own
  2. add a `COPY values.envsh /docker-entrypoint.d
  3. create values.envsh with #! /bin/sh export VALUE=test and make the script executable
  4. attempt to run a container from the custom image

Expected behavior

I expect values.envsh to be sourced

Your environment

  • Version of Docker: Docker version 20.10.12, build e91ed57
  • Version of the NGINX Unprivileged Docker image: 1.23
  • Target deployment environment/platform: Ubuntu 20.04

eerotki

I discovered that startup script 20-envsubst-on-templates.sh takes longer than expected to execute with the recent update, when /etc/nginx/conf.d/ path is in read-only mode. With 1.23.0-alpine, the container is started in 4 seconds, from creation to serving traffic. While in 1.23.1-alpine, the same configuration with same computing resources takes up to 120 seconds to start. The script 20-envsubst-on-templates.sh alone took 118 seconds to process. My configuration expects the container to start within 35 seconds, which has been plenty with version prio to 1.23.1. Adjusting conf.d path to read-write for 1.23.1-alpine reduces the startup time as it was, to 4 seconds.

I’m using GKE 1.22 + Docker 20.10.6 with small resources (25m CPU, 50Mi RAM). This configuration has been working flawlessly in the past years. When ran locally with my mighty laptop the start up is pretty much instantaneous. The issue can be bypassed in K8s by either allowing more time for the container to start, or just by increasing allocated CPU resource (doubling it reduces container startup time to 60 seconds).

I think it’d be ideal to discuss whether this behaviour was expected and can we expect it to stay like this in future updates?

damianoneill

Hi, thanks in advance. I’m trying to understand what OSS is used in the image. Is this documented anywhere?

Thanks,
Damian.

sagiru

Description

Hi,

we have the requirement to use the module nginx-mod-http-headers-more in our docker images. If we use the nginx-unprivileged:1.22.0-alpine or the nginx-unprivileged:1.23.1-alpine and add the module we got two different error but it does not work with any of them.

If we use 1.22.0 and add the both lines in any dockerfile from below we got the following error:

sascha@marge: $ docker run nginx-sidecar:latest
/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: /etc/nginx/conf.d/default.conf differs from the packaged version
/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
2022/09/09 13:27:28 [emerg] 1#1: module "/usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so" is not binary compatible in /etc/nginx/nginx.conf:1
nginx: [emerg] module "/usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so" is not binary compatible in /etc/nginx/nginx.conf:1

If we use 1.23.1 and add the both lines in any dockerfile from below we got the following, slightly different error:

sascha@marge: $ docker run nginx-sidecar:latest
/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/watcher-launcher.sh
/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: /etc/nginx/conf.d/default.conf differs from the packaged version
/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
2022/09/09 13:08:57 [emerg] 1#1: module "/usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so" version 1022000 instead of 1023001 in /etc/nginx/nginx.conf:1
nginx: [emerg] module "/usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so" version 1022000 instead of 1023001 in /etc/nginx/nginx.conf:1

To reproduce

Use the following dockerfile and do a docker build. After a docker run you will get the errors.

FROM docker-proxy.central.aws.aok-systems.de/nginxinc/nginx-unprivileged:1.23.1-alpine

USER root

RUN apk add --no-cache nginx-mod-http-headers-more
RUN echo "load_module /usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so;" > /etc/nginx/nginx.conf

USER nginx

Your environment

  • Version of Docker
  • Version of the NGINX Unprivileged Docker image
    • 1.22.0-alpine
    • 1.23.1-alpine
  • Target deployment environment/platform
    • Local Docker, Openshift and eks

lioman

Describe the bug

If you use nginx templating function the filled template can not be saved if /etc/nginx/conf.d is not writable.

To reproduce

Steps to reproduce the behavior:

  1. Build a NGINX Unprivileged Docker image with an default.conf.template in /etc/nginx/templates
  2. Deploy the container in environment, where only /tmp is writable
  3. See error in log, that template can not be written to /etc/nginx/conf.d

Expected behavior

In a unprivileged environment, I expect, that templates ca be written and used.

У меня проблема с настройкой сервера nginx с помощью docker и django.
Вот моя структура каталогов

-nginx
--default.conf
--Dockerfile
-portfolio_app (django webpapp)
--main_app
---settings.py
---wsgi.py
--sub_app
---views.py
---static
---media
-docker-compose.yml
-Dockerfile (django related)
-entrypoint.sh (to start django server)

Что касается django, то он работает, но я не могу обслуживать статические файлы. Мне кажется, я неправильно указываю путь.

Здесь находится Dockerfile, связанный с django

FROM python:3.8.13-slim-buster

WORKDIR /app
RUN pip install --upgrade pip
COPY ./requirements.txt ./
RUN pip install -r requirements.txt

COPY ./portfolio_app ./

COPY ./entrypoint.sh ./
ENTRYPOINT ["sh","/app/entrypoint.sh"]

nginx файлы
default.conf

upstream django{
    server portfolio_app:8000;
}

server {
    listen 80;

    location /{
        proxy_pass http://django;
    }

    location /static/ {
        alias sub_app/static/;
    }

}

Dockerfile

FROM nginx:1.19.0-alpine
COPY ./default.conf /etc/nginx/conf.d/default.conf

Вот файл docker-compose.yml

version: '3.3'
services:
  portfolio_app:
    build: .
    container_name: portfolio_app
    volumes:
      - static_volume:/sub_app/static
      - media_volume:/sub_app/media
    ports:
      - "8000:8000"
    env_file:
      - .env

  nginx:
    build: ./nginx
    volumes:
      - static_volume:/sub_app/static
      - media_volume:/sub_app/media
    ports:
      - "80:80"
    depends_on:
      - portfolio_app


volumes:
  media_volume:
  static_volume:

Я не уверен в пути к томам в yml файле и настройках default.conf.
Вот журналы

Successfully built 8459b7bb3baf
Successfully tagged docker_nginx:latest
Recreating b0f1b634454f_portfolio_app ... done
Recreating docker_nginx_1             ... done
Attaching to portfolio_app, docker_nginx_1
nginx_1          | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx_1          | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx_1          | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
portfolio_app    | [2022-07-21 08:09:47 +0000] [7] [INFO] Starting gunicorn 20.1.0
nginx_1          | 10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
portfolio_app    | [2022-07-21 08:09:47 +0000] [7] [INFO] Listening at: http://0.0.0.0:8000 (7)
portfolio_app    | [2022-07-21 08:09:47 +0000] [7] [INFO] Using worker: sync
nginx_1          | 10-listen-on-ipv6-by-default.sh: /etc/nginx/conf.d/default.conf differs from the packages version, exiting
portfolio_app    | [2022-07-21 08:09:47 +0000] [9] [INFO] Booting worker with pid: 9
nginx_1          | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx_1          | /docker-entrypoint.sh: Configuration complete; ready for start up
portfolio_app    | Not Found: /static/lib/animate/animate.min.css

Редактировать
Вот как я добавил статические url и файл в settings.py

MEDIA_ROOT = os.path.join(BASE_DIR, 'sub_app','media') 
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'sub_app','static')

default.conf:

вместо этого:

location /static/ {
        alias sub_app/static/;
    }

попробуйте это:

location /static/ {
        alias ./static/;
    }

В вашей службе nginx вы смонтировали том, как показано ниже. Где static_volume — том хоста, а /app/sub_app/static — каталог контейнера, куда он смонтирован.

static_volume:/app/sub_app/static

Но в конфигурационном файле nginx вы направляете статические запросы на /static_volume/. Вместо этого вам нужно указать его на каталог вашего контейнера, как показано ниже

location /static/ {
        alias /app/sub_app/static/;
    }

Вернуться на верх

Понравилась статья? Поделить с друзьями:
  • Error establishing a database connection что это значит
  • Error establishing a database connection wordpress что делать
  • Error establishing a database connection wordpress multisite
  • Error establishing a database connection wordpress centos
  • Error establishing a database connection ubuntu wordpress