question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error in nginx config with Docker

See original GitHub issue

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.

frontend_1       | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
frontend_1       | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
frontend_1       | 20-envsubst-on-templates.sh: Running envsubst on /etc/nginx/templates/default.conf.template to /etc/nginx/conf.d/default.conf
frontend_1       | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
frontend_1       | /docker-entrypoint.sh: Configuration complete; ready for start up
frontend_1       | 2022/03/15 04:12:36 [emerg] 1#1: invalid variable name in /etc/nginx/nginx.conf:37
frontend_1       | nginx: [emerg] invalid variable name in /etc/nginx/nginx.conf:37
xx_frontend_1 exited with code 1

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
  2. docker-compose --project-name xx -f ~/app/erpnext/docker-compose.yml up

nginx.conf as extracted from container

docker run -it frappe/erpnext-nginx:v13.22.1 cat -n /etc/nginx/nginx.conf
     1	
     2	worker_processes  auto;
     3	
     4	error_log  /var/log/nginx/error.log notice;
     5	pid        /tmp/nginx.pid;
     6	
     7	
     8	events {
     9	    worker_connections  1024;
    10	}
    11	
    12	
    13	http {
    14	    proxy_temp_path /tmp/proxy_temp;
    15	    client_body_temp_path /tmp/client_temp;
    16	    fastcgi_temp_path /tmp/fastcgi_temp;
    17	    uwsgi_temp_path /tmp/uwsgi_temp;
    18	    scgi_temp_path /tmp/scgi_temp;
    19	
    20	    include       /etc/nginx/mime.types;
    21	    default_type  application/octet-stream;
    22	
    23	    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    24	                      '$status $body_bytes_sent "$http_referer" '
    25	                      '"$http_user_agent" "$http_x_forwarded_for"';
    26	
    27	    access_log  /var/log/nginx/access.log  main;
    28	
    29	    sendfile        on;
    30	    #tcp_nopush     on;
    31	
    32	    keepalive_timeout  65;
    33	
    34	    #gzip  on;
    35	
    36	    include /etc/nginx/conf.d/*.conf;
    37	}

Stacktrace / full error message if available

db_1             | 2022-03-15 04:12:29+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.6.7+maria~focal started.
db_1             | 2022-03-15 04:12:29+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1             | 2022-03-15 04:12:29+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.6.7+maria~focal started.
db_1             | 2022-03-15 04:12:29+00:00 [Note] [Entrypoint]: MariaDB upgrade not required
db_1             | 2022-03-15  4:12:29 0 [Note] mariadbd (server 10.6.7-MariaDB-1:10.6.7+maria~focal) starting as process 1 ...
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: Number of pools: 1
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
db_1             | 2022-03-15  4:12:30 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: Using Linux native AIO
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: Completed initialization of buffer pool
xx_configurator_1 exited with code 0
frontend_1       | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
frontend_1       | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
frontend_1       | /docker-entrypoint.sh: Launching /docker-entrypoint.d/frappe-entrypoint.sh
frontend_1       | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: 128 rollback segments are active.
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: 10.6.7 started; log sequence number 42575; transaction id 14
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db_1             | 2022-03-15  4:12:30 0 [Note] Plugin 'FEEDBACK' is disabled.
frontend_1       | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
db_1             | 2022-03-15  4:12:30 0 [Note] InnoDB: Buffer pool(s) load completed at 220315  4:12:30
db_1             | 2022-03-15  4:12:30 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
db_1             | 2022-03-15  4:12:30 0 [Note] Server socket created on IP: '0.0.0.0'.
db_1             | 2022-03-15  4:12:30 0 [Note] Server socket created on IP: '::'.
db_1             | 2022-03-15  4:12:30 0 [Note] mariadbd: ready for connections.
db_1             | Version: '10.6.7-MariaDB-1:10.6.7+maria~focal'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
redis_1          | 1:C 15 Mar 2022 04:12:29.470 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1          | 1:C 15 Mar 2022 04:12:29.470 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1          | 1:C 15 Mar 2022 04:12:29.470 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1          | 1:M 15 Mar 2022 04:12:29.470 * monotonic clock: POSIX clock_gettime
redis_1          | 1:M 15 Mar 2022 04:12:29.474 * Running mode=standalone, port=6379.
redis_1          | 1:M 15 Mar 2022 04:12:29.474 # Server initialized
redis_1          | 1:M 15 Mar 2022 04:12:29.474 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1          | 1:M 15 Mar 2022 04:12:29.474 * Loading RDB produced by version 6.2.6
redis_1          | 1:M 15 Mar 2022 04:12:29.474 * RDB age 81 seconds
redis_1          | 1:M 15 Mar 2022 04:12:29.474 * RDB memory usage when created 0.80 Mb
redis_1          | 1:M 15 Mar 2022 04:12:29.474 # Done loading RDB, keys loaded: 10, keys expired: 0.
redis_1          | 1:M 15 Mar 2022 04:12:29.474 * DB loaded from disk: 0.000 seconds
redis_1          | 1:M 15 Mar 2022 04:12:29.474 * Ready to accept connections
frontend_1       | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
frontend_1       | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
frontend_1       | 20-envsubst-on-templates.sh: Running envsubst on /etc/nginx/templates/default.conf.template to /etc/nginx/conf.d/default.conf
frontend_1       | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
frontend_1       | /docker-entrypoint.sh: Configuration complete; ready for start up
frontend_1       | 2022/03/15 04:12:36 [emerg] 1#1: invalid variable name in /etc/nginx/nginx.conf:37
frontend_1       | nginx: [emerg] invalid variable name in /etc/nginx/nginx.conf:37
xx_frontend_1 exited with code 1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
vrslevcommented, 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”.

1reaction
1ubuntuusercommented, Mar 18, 2022

Ahh, now I get it. It’s been a big week and I’m a little slow. Thanks for helping me understand.

On Fri, 18 Mar 2022, 10:57 pm Jonas Weigand, @.***> wrote:

@1ubuntuuser https://github.com/1ubuntuuser I think you misunderstood. @vrslev https://github.com/vrslev is correct in his answer. Let me elaborate:

compose.yaml contains the following:

frontend:

depends_on:

  backend:

    condition: service_started

  websocket:

    condition: service_started

environment:

  BACKEND: backend:8000

  FRAPPE_SITE_NAME_HEADER: $$host

  SOCKETIO: websocket:9000

  UPSTREAM_REAL_IP_ADDRESS: 127.0.0.1

  UPSTREAM_REAL_IP_HEADER: X-Forwarded-For

  UPSTREAM_REAL_IP_RECURSIVE: "off"

Notice the $$host. with Compose v1

I ran into problems using docker-compose v1 (docker-compose -v:). The command docker-compose -f compose.yaml parses the line to

FRAPPE_SITE_NAME_HEADER: $$$$host

So we would ne 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

FRAPPE_SITE_NAME_HEADER: $$host

Here two $$ are fine. Ideas for Mitigation

As @vrslev https://github.com/vrslev mentioned, there is not really a way to fix this universally. One idea would be to outsource the creation of the final docker-compose.yaml file (with docker-compose -f compose.yaml <overwrites> config) to a shell-file that checks for the version of docker-compose and makes the necessary changes. I think this is convoluted and doesn‘t protect users from using docker-compose config directly anyway. The best way for now is probably a line in the documentation informing users to upgrade to docker-compose v2, or inform about the $$ problem when using v1.

— Reply to this email directly, view it on GitHub https://github.com/frappe/frappe_docker/issues/701#issuecomment-1072341655, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEEAOS3KOZ3G3X5YWP2ID43VARVS3ANCNFSM5QXQC43A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nginx error in a docker container
I have a flask app that I'm trying to run in a docker container. Docker-compose build and docker-compose up both run fine, but...
Read more >
open() "/etc/nginx/nginx.conf" failed (2: No such file or ...
Hi, I have a problem on my basic configuration with my environment with nginx,mysql,wordpress,mediawiki (local on Windows 10 PC).
Read more >
How to Deploy an NGINX Image with Docker
This post explains how to: Deploy NGINX Open Source using the image from Docker Hub; Manage NGINX in the container (connecting to, configuring, ......
Read more >
Nginx container returning an error with Exit code 1 [emerg] ...
... "enable" in /etc/nginx/nginx.conf:45. Posted on June 14, 2021; NginxDockerServer Optimization. cihatsaman Asked by cihatsaman. I have 2 servers one is ...
Read more >
Docker nginx ssl error
You are copying the certificate files and the nginx config in the api container. You need to mount the files in the nginx...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found