【发布时间】:2017-02-19 11:16:02
【问题描述】:
我正在尝试反向代理一个 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 configuration reverse-proxy