Warm tip: This article is reproduced from serverfault.com, please click

How fix nginx error "invalid number of arguments"?

发布于 2020-12-13 16:21:41

i try redirect to proxy-server nginx.

        location /phpmyadmin {
        proxy_http_version 1.1;
        proxy_pass https://${PMA}:5000/;
        proxy_set_header Host      $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

But i get error:

nginx: [emerg] invalid number of arguments in "proxy_set_header" directive in /etc/nginx/nginx.conf:26

full code for inspect error in this listing, because i'm real can't find some error's (${env} = correctry changing in script

user root;
worker_processes auto;
pcre_jit on;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    keepalive_timeout 3000;
    sendfile on;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    server {
        listen 443 ssl;
        listen [::]:443 ssl;
        ssl_certificate /etc/ssl/nginx.crt;
        ssl_certificate_key /etc/ssl/nginx.key;
        root /home;
        index default.html /default.html;
        location /phpmyadmin {
            proxy_http_version 1.1;
            proxy_pass https://${PMA}:5000/;
            proxy_set_header Host $host;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-Proto https;
        }
        location /wordpress {
            return 307 http://${WP}:5050/;
        }
        location / {
            try_files /default.html default.html default.htm;
        }
    }
    server {
        listen 80;
        listen [::]:80;

        return 301 https://$host$request_uri;
    }
}
daemon off;

how much simvols need for post)

Questioner
Mikhail Prigorodov
Viewed
0
Mikhail Prigorodov 2020-12-15 00:12:20

I used envsubst for environment replacing, and this util tried swap $host and other nginx envs, solved with:

envsubst '\$WP \$PMA' < nginx.template.conf > nginx.ready.conf; rm nginx.template.conf