我正在尝试在 nginx 后面运行和使用 docker 作为反向代理。一切正常,除非 docker 使用原始流"application/vnd.docker.raw-stream"
而不是正常的 HTTP 响应进行响应。此处记录的端点/start
,/attach
等会发生这种情况:https ://docs.docker.com/engine/api/v1.21/#operation/ExecStart
这是我的 nginx 配置没有将 docker 响应转发给客户端的时候。我尝试搜索它,只有一篇博客文章建议对实际的 nginx C 文件进行补丁:https ://blog.yadutaf.fr/2014/12/12/how-to-run-docker-behind-an-nginx-反向代理/
我完全按照上面的博客进行了操作,但是,设置似乎对docker 中的 HTTP 端点r->upstream->upgrade = 1;
没有影响。/start
Nginx 根本没有响应。有没有办法解决?这是我目前的 nginx.conf 文件:
daemon off;
error_log /dev/stdout info;
# error_log logs/error.log debug;
events {
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
# include mime.types;
# default_type application/octet-stream;
# sendfile on;
# keepalive_timeout 65;
upstream dockerpool {
# session_sticky cookie=sessionid fallback=off mode=insert option=indirect;
# backup server
# server nginx_dev_test:80;
server socat:2376;
}
server {
listen 80;
location / {
# The upstream here must be a nginx variable
set $ups dockerpool;
proxy_buffering off;
proxy_pass http://$ups;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
}