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

reverse proxy-如何解决nginx错误“无效的参数数量”?

(reverse proxy - How fix nginx error "invalid number of arguments"?)

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

我尝试重定向到代理服务器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;
    }

但我得到错误:

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

此清单中检查错误的完整代码,因为我是真的找不到某些错误($ {env} =脚本中的更正更改

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;

需要多少simvols才能发布)

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

我使用envsubst进行环境替换,并且该util尝试交换$ host和其他nginx envs,解决方法是:

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