Problem running nginx in a container

marioja2 nginx-forum at forum.nginx.org
Fri Feb 4 23:33:08 UTC 2022


I am running nginx in a container created with a docker-compose yaml file. 
Here is a sample docker-compose.yml and environment file:

https://github.com/marioja/Mailu/tree/test-mailu/test-mailu-docker-compose.

The marioja/rainloop:1.9.TEST image is created using this Dockerfile in
GitHub:

https://github.com/marioja/Mailu/blob/test-mailu/webmails/rainloop/Dockerfile


The really interesting problem (I have been working on it for 3 days just so
you know I am not asking for help without having tried a lot of things
before) is that the configuration entries in the
/etc/nginx/http.d/rainloop.conf configuration file created when the rainloop
image starts from the webmails/rainloop/config/nginx-rainloop.conf in the
github branch previously mentioned is not recognized by nginx when the
webmail container (using the rainloop image) is started by docker-compose up
-d.  However, if I restart the webmail container using docker-compose
restart webmail then the instructions in that rainloop.conf are then
recognized by nginx.  I tried to use nginx-debug with error_log set to debug
but the output I get is not understandable and does not refer to any config
file path or parsing.

The reason I am asking this in the nginx mailing list is because I have
exhausted all of the tests that can gather information from the container
side and I am wondering if there is anything that you guys can thing that
could explain this.  Here is the directory structure of the files in the
container where nginx is running before starting as a result of the
docker-compose up -d:

@@@ /var/lib/nginx
/var/lib/nginx:
total 16
drwxr-x---    4 nginx    nginx         4096 Feb  1 15:55 .
drwxr-xr-x    1 root     root          4096 Feb  1 15:55 ..
drwxr-xr-x    2 root     root          4096 Feb  1 15:55 html
lrwxrwxrwx    1 root     root            14 Feb  1 15:55 logs ->
/var/log/nginx
lrwxrwxrwx    1 root     root            22 Feb  1 15:55 modules ->
/usr/lib/nginx/modules
lrwxrwxrwx    1 root     root            10 Feb  1 15:55 run -> /run/nginx
drwx------    2 nginx    nginx         4096 Feb  1 15:55 tmp

/var/lib/nginx/html:
total 16
drwxr-xr-x    2 root     root          4096 Feb  1 15:55 .
drwxr-x---    4 nginx    nginx         4096 Feb  1 15:55 ..
-rw-r--r--    1 root     root           494 Nov 17 13:20 50x.html
-rw-r--r--    1 root     root           612 Nov 17 13:20 index.html

/var/lib/nginx/tmp:
total 8
drwx------    2 nginx    nginx         4096 Feb  1 15:55 .
drwxr-x---    4 nginx    nginx         4096 Feb  1 15:55 ..
@@@ /etc/nginx
/etc/nginx:
total 52
drwxr-xr-x    1 root     root          4096 Feb  1 15:55 .
drwxr-xr-x    1 root     root          4096 Feb  3 02:53 ..
-rw-r--r--    1 root     root          1077 Nov 17 13:20 fastcgi.conf
-rw-r--r--    1 root     root          1007 Nov 17 13:20 fastcgi_params
drwxr-xr-x    1 root     root          4096 Feb  3 02:53 http.d
-rw-r--r--    1 root     root          5231 Nov 17 13:20 mime.types
drwxr-xr-x    2 root     root          4096 Feb  1 15:55 modules
-rw-r--r--    1 root     root          3358 Feb  1 15:55 nginx.conf
-rw-r--r--    1 root     root           636 Nov 17 13:20 scgi_params
-rw-r--r--    1 root     root           664 Nov 17 13:20 uwsgi_params

/etc/nginx/http.d:
total 16
drwxr-xr-x    1 root     root          4096 Feb  3 02:53 .
drwxr-xr-x    1 root     root          4096 Feb  1 15:55 ..
-rw-r--r--    1 root     root           914 Feb  3 02:53 rainloop.conf

/etc/nginx/modules:
total 12
drwxr-xr-x    2 root     root          4096 Feb  1 15:55 .
drwxr-xr-x    1 root     root          4096 Feb  1 15:55 ..
@@@ /var/log/nginx
/var/log/nginx:
total 12
drwxr-xr-x    2 nginx    nginx         4096 Feb  1 15:55 .
drwxr-xr-x    1 root     root          4096 Feb  1 15:55 ..
@@@ /run/nginx
/run/nginx:
total 8
drwxr-xr-x    2 nginx    nginx         4096 Feb  1 15:55 .
drwxr-xr-x    1 root     root          4096 Feb  3 02:53 ..
@@@ /usr/lib/nginx
/usr/lib/nginx:
total 12
drwxr-xr-x    3 root     root          4096 Feb  1 15:55 .
drwxr-xr-x    1 root     root          4096 Feb  1 15:55 ..
drwxr-xr-x    2 root     root          4096 Feb  1 15:55 modules

/usr/lib/nginx/modules:
total 8
drwxr-xr-x    2 root     root          4096 Feb  1 15:55 .
drwxr-xr-x    3 root     root          4096 Feb  1 15:55 ..

This is the content of the rainloop.conf in the webmail container at
runtime:

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

    root /var/www/rainloop;

    # /dev/stdout (Default), <path>, off
    access_log off;

    # /dev/stderr (Default), <path>, debug, info, notice, warn, error, crit,
alert, emerg
    error_log /dev/stderr warn;

    index index.php;

    # set maximum body size to configured limit
    client_max_body_size 58388608;

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

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.*)$;

        fastcgi_intercept_errors on;
        fastcgi_index  index.php;

        fastcgi_keep_conn on;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/php7-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.ht {
        deny all;
    }

    location ^~ /data {
      deny all;
    }
}

Is there a way to tell nginx or nginx-debug to tell us what is going on? 
The error that occurs after docker-compse up -d is that a 5MB attachment
posted to the webmail container fails.  That same 5MB attachment works after
a docker-compose restart.  The statement that does not appear to take effect
until the docker-compose restart is the client_max_body_size 58388608. 
Please note that there is a client_max_body_size 1m directive in the
/etc/nginx/nginx.conf during both restart (docker-compose up and
docker-compose restart).

I have searched low and high for any information about this http.d directory
but I could not see anything.  I am using nginx version 1.20.2 installed
from alpinelinux apk command.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,293592,293592#msg-293592



More information about the nginx mailing list