nginx反向代理dockerui出错

nginx反向代理dockerui出错。症状是通过nginx访问会下载名为dockerui的可执行程序。反向代理配置如下:

    # reverse proxy to dockerui webapp
    location /dockerui {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_http_version 1.1;
        proxy_pass   http://127.0.0.1:4234;
    }

 通过nginx的请求测试:

-bash-3.2$ curl -v -i  http://docker.homenet/dockerui > resp.out
* Hostname was NOT found in DNS cache
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 192.168.1.51...
* Connected to docker.homenet (192.168.1.51) port 80 (#0)
> GET /dockerui HTTP/1.1
> User-Agent: curl/7.37.1
> Host: docker.homenet
> Accept: */*
> 
< HTTP/1.1 200 OK
* Server nginx/1.6.2 is not blacklisted
< Server: nginx/1.6.2
< Date: Thu, 09 Apr 2015 14:33:48 GMT
< Content-Type: application/octet-stream
< Content-Length: 4267072
< Connection: keep-alive
< Accept-Ranges: bytes
< Last-Modified: Fri, 03 Apr 2015 16:35:25 GMT
< 
{ [data not shown]
100 4167k  100 4167k    0     0  7417k      0 --:--:-- --:--:-- --:--:-- 7414k
* Connection #0 to host docker.homenet left intact

 不通过nginx,直接连dockerui的web服务的测试:

-bash-3.2$ curl -v -i  http://docker.homenet:4234 > resp1.out
* Rebuilt URL to: http://docker.homenet:4234/
* Hostname was NOT found in DNS cache
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 192.168.1.51...
* Connected to docker.homenet (192.168.1.51) port 4234 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.37.1
> Host: docker.homenet:4234
> Accept: */*
> 
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 1927
< Content-Type: text/html; charset=utf-8
< Last-Modified: Fri, 03 Apr 2015 16:35:25 GMT
< Date: Thu, 09 Apr 2015 14:34:31 GMT
< 
{ [data not shown]
100  1927  100  1927    0     0   197k      0 --:--:-- --:--:-- --:--:--  209k
* Connection #0 to host docker.homenet left intact

原因是dockerui这个web应用使用名为dockerui的可执行程序提供web服务,但是对/dockerui这样的请求没有处理好,直接作为静态文件下载了。

你可能感兴趣的:(docker)