Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
nginx';“中的参数数无效”;“地图”;指令';_Nginx_Configuration_Reverse Proxy - Fatal编程技术网

nginx';“中的参数数无效”;“地图”;指令';

nginx';“中的参数数无效”;“地图”;指令';,nginx,configuration,reverse-proxy,Nginx,Configuration,Reverse Proxy,我正在尝试反向代理websocket,我以前使用nginx做过,没有任何问题。奇怪的是,我似乎不能用这么简单的事情来重建我以前的成功。我一遍又一遍地查看配置文件,但似乎找不到我的错误 这是我的完整default.conf: map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; location /api/ { proxy_pass ${A

我正在尝试反向代理websocket,我以前使用nginx做过,没有任何问题。奇怪的是,我似乎不能用这么简单的事情来重建我以前的成功。我一遍又一遍地查看配置文件,但似乎找不到我的错误

这是我的完整
default.conf

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

server {
  listen 80;

  location /api/ {
    proxy_pass ${API_LOCATION};
  }

  location / {
    proxy_pass ${UI_LOCATION};
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
  }
}
我得到的错误是:

2016/10/10 23:30:24 [emerg] 8#8: invalid number of arguments in "map" directive in /etc/nginx/conf.d/default.conf:1
nginx: [emerg] invalid number of arguments in "map" directive in /etc/nginx/conf.d/default.conf:1
以及我使用的确切Dockerfile,以防您想要复制我的设置(相对于Dockerfile将
default.conf
另存为
conf.templates/default.conf

FROM nginx
COPY conf /etc/nginx/conf.templates
CMD /bin/bash -c "envsubst < /etc/nginx/conf.templates/default.conf > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
来自nginx的

复制conf/etc/nginx/conf.templates
CMD/bin/bash-c“envsubt/etc/nginx/conf.d/default.conf&&nginx-g‘守护进程关闭’”

使用
envsubt
命令替换所有出现的
$vars
,包括
$http\u-upgrade
$connection\u-upgrade
。 您应该提供要替换的变量列表,例如:

 envsubst '${API_LOCATION},${UI_LOCATION}' < /etc/nginx/conf.templates/default.conf

你是个救生员!!还有,这是常见的吗?这就像我搜索查询的第一个结果,我甚至没有在查询中键入
docker
FROM nginx
COPY conf /etc/nginx/conf.templates
CMD /bin/bash -c "envsubst '$${API_LOCATION},$${UI_LOCATION}' < /etc/nginx/conf.templates/default.conf > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"