大佬教程收集整理的这篇文章主要介绍了nginx’“map”指令中的参数数量无效,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试反向代理一个websocket,我之前用Nginx做过没有问题.奇怪的是,我似乎无法通过如此简单的事情重新创造我之前的成功.我已经遍历配置文件,但似乎无法找到我的错误.
这是我的完整default.conf:
@H_655_7@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保存为相对于Dockerfile的conf.templates / default.conf:
FROM Nginx
copY conf /etc/Nginx/conf.templates
CMD /bin/bash -c "envsubst <>Nginx/conf.templates/default.conf > /etc/Nginx/conf.d/default.conf && Nginx -g 'daemon off;'"
envsubst '${API_LOCATION},${UI_LOCATION}' <>Nginx/conf.templates/default.conf
另见:replacing only specific variables with envsubst
此外,在docker-compose配置中,您应该使用double $$转义来禁用变量替换:
FROM Nginx
copY conf /etc/Nginx/conf.templates
CMD /bin/bash -c "envsubst '$${API_LOCATION},$${UI_LOCATION}' <>Nginx/conf.templates/default.conf > /etc/Nginx/conf.d/default.conf && Nginx -g 'daemon off;'"
以上是大佬教程为你收集整理的nginx’“map”指令中的参数数量无效全部内容,希望文章能够帮你解决nginx’“map”指令中的参数数量无效所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。