nginx代理背后的大厅ci

时间:2017-03-10 10:27:01

标签: nginx proxy concourse

export CONCOURSE_BIND_PORT=9000
export CONCOURSE_BIND_IP=5.6.7.8 # dummy internal ip
export CONCOURSE_EXTERNAL_URL=http://ci.ratpoison.io

docker run --rm \
    --expose ${CONCOURSE_BIND_PORT} \
    -v /path/to/concourse/keys/web:/concourse-keys \
    --net=lonelyisland \
    --ip=${CONCOURSE_BIND_IP} \
    concourse/concourse:latest web \
        --basic-auth-username=${CONCOURSE_BASIC_AUTH_USERNAME} \
        --basic-auth-password=${CONCOURSE_BASIC_AUTH_PASSWORD} \
        --bind-ip=${CONCOURSE_BIND_IP} \
        --bind-port=${CONCOURSE_BIND_PORT} \
        --external-url=${CONCOURSE_EXTERNAL_URL} \
        --postgres-data-source=${CONCOURSE_POSTGRES_DATA_SOURCE}

nginx代理infront配置为:

user nginx nginx;
worker_processes 4;
worker_rlimit_nofile 8192;

events {
  worker_connections  512;
}



http {

upstream concourse {
    server 5.6.7.8:9000;
}

server {
    listen 80 http2;
    listen [::]:80 http2;
    server_name ci.ratpoison.io;

    location / {
                proxy_pass      http://concourse;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
                access_log      /log/ci.access.log;
                error_log       /log/ci.error.log;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        # Fix `websocket: bad handshake` when using `fly intercept`
        proxy_set_header  Upgrade $http_upgrade;
        proxy_set_header  Connection "upgrade";

        # Fix appears that your reverse proxy set up is broken" error.
        proxy_read_timeout  90;

        proxy_redirect  http://concourse http://ci.ratpoison.io;
        proxy_buffering off;
    }
}

}

通过

使用
docker run -p 80:80 -p 443:443 --rm --name proxy --net lonelyisland -v /var/log/proxy:/log -v /path/to/proxy.conf:/etc/nginx/nginx.conf quay.io/ahoi/proxy:latest

具体内容和评论取自http://engineering.pivotal.io/post/concourse-no-elb/

lonelyisland docker创建的网络中访问它可以正常工作:

curl -vvvI 5.6.7.8:9000
* Rebuilt URL to: 5.6.7.8:9000/
*   Trying 5.6.7.8...
* TCP_NODELAY set
* Connected to 5.6.7.8 (5.6.7.8) port 9000 (#0)
> HEAD / HTTP/1.1
> Host: 5.6.7.8:9000
> User-Agent: curl/7.52.1
> Accept: */*
> 
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Date: Fri, 10 Mar 2017 10:28:12 GMT
Date: Fri, 10 Mar 2017 10:28:12 GMT
< Content-Type: text/html; charset=utf-8
Content-Type: text/html; charset=utf-8

< 
* Curl_http_done: called premature == 0
* Connection #0 to host 5.6.7.8 left intact

从公众开始,当我运行curl -vvI ci.ratpoison.io时,我得到的是:

* Rebuilt URL to: ci.ratpoison.io/
*   Trying 2a02:2770:3:0:21a:4aff:fe27:e918...
* Connected to ci.ratpoison.io (2a02:2770:3:0:21a:4aff:fe27:e918) port 80 (#0)
> HEAD / HTTP/1.1
> Host: ci.ratpoison.io
> User-Agent: curl/7.49.0
> Accept: */*
> 
* Connection #0 to host ci.ratpoison.io left intact
����%     

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

listen 80 http2;
listen [::]:80 http2;

必须更改为

listen 80;
listen [::]:80;

它似乎不是firfox和curl的用例,或http2模块使用没有ssl的http / 2。