0
我試圖反向代理一個websocket,我之前用nginx做了一個沒有問題的代理。奇怪的是,我似乎無法用這麼簡單的事情重新創造我的成功。我一直在配置文件,但似乎無法找到我的錯誤。nginx'map'指令中參數的無效數
這裏是我的全部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(保存default.conf
as conf.templates/default.conf
相對於Dockerfile:
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;'"