nginx icon indicating copy to clipboard operation
nginx copied to clipboard

arm64 container include config can't read map variable.

Open wcollin opened this issue 1 year ago • 2 comments

Environment

Include the result of the following commands:

  • nginx version: nginx/1.25.3 built by gcc 12.2.0 (Debian 12.2.0-14) built with OpenSSL 3.0.9 30 May 2023 (running with OpenSSL 3.0.11 19 Sep 2023) TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -ffile-prefix-map=/data/builder/debuild/nginx-1.25.3/debian/debuild-base/nginx-1.25.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'

  • Linux evm-6lak7b9r9kow 4.19.90-52.22.v2207.ky10.aarch64 #1 SMP Tue Mar 14 11:52:45 CST 2023 aarch64 aarch64 aarch64 GNU/Linux

Description

http include config file can't read map variable。error is unknown "myvar" variable。when i move map to http.conf,it works well。

nginx configuration

#user nobody; worker_processes 1;

#error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;

#pid logs/nginx.pid;

events { worker_connections 1024; }

http { include mime.types; default_type application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

map $http_origin $myvar {
    default '';
    "http://test.abc.com" "http://test.abc.com";
}
include http.conf;

}

http.conf server { listen 80; server_name test.abc.com;

location / {
    root   html;
    index  index.html index.htm;
    add_header Access-Control-Allow-Origin $myvar;
}

}

wcollin avatar Sep 20 '24 08:09 wcollin

Hi @wcollin !

Can you show how you launch the container and populate the filesystem? e.g. how are nginx.conf and http.conf make their way inside?

Thanks,

thresheek avatar Sep 20 '24 17:09 thresheek

Hi @wcollin !

Can you show how you launch the container and populate the filesystem? e.g. how are nginx.conf and http.conf make their way inside?

Thanks,

i use docker-compose, this is my docker-compose.yaml: version: "3"

services: nginx: container_name: nginx image: nginx:1.25.3 environment: TZ: "Asia/Shanghai" ports: - "80:80" - "443:443" volumes: - ${DATADIR:-.}/nginx-data/conf/nginx.conf:/etc/nginx/nginx.conf:ro - ${DATADIR:-.}/nginx-data/conf/mime.types:/etc/nginx/mime.types:ro - ${DATADIR:-.}/nginx-data/conf/conf.d:/etc/nginx/conf.d:ro - ${DATADIR:-.}/nginx-data/ssl:/etc/nginx/ssl:ro - ${DATADIR:-.}/nginx-data/logs:/var/log/nginx:rw - ${DATADIR:-.}/nginx-static:/data/nginx-static:ro restart: always deploy: resources: limits: memory: 4G reservations: memory: 256M ulimits: nofile: soft: 65535 hard: 65535 sysctls: - net.core.somaxconn=2048

wcollin avatar Sep 24 '24 04:09 wcollin

Hi @wcollin,

With that docker-compose configuration I don't understand how 'http.conf' gets inside a container alongside (in the same directory) as nginx.conf - as you're doing an include through 'include http.conf;' and not 'include conf.d/http.conf;':

nginx: [emerg] open() "/etc/nginx/http.conf" failed (2: No such file or directory) in /etc/nginx/nginx.conf:36

If you mount the file as:

- ${DATADIR:-.}/nginx-data/conf/conf.d/http.conf:/etc/nginx/http.conf:ro

It works fine and the variable is getting picked up.

Can you clarify the exact configuration you're using?

thresheek avatar Jan 16 '25 22:01 thresheek

This issue has been open for a long time without any additional details being provided. Closing it due to inactivity.

Maryna-f5 avatar May 30 '25 17:05 Maryna-f5