docker-compose错误与ghost和nginx代理

时间:2015-12-12 21:58:09

标签: nginx docker docker-compose ghost

所以,我开始使用docker-compose

现在,我遇到了nginx代理请求的问题。

所以我有一个使用鬼影的容器,并在2368曝光:

ghostblog:
  container_name: ghostblog
  image: ghost
  restart: always
  ports:
    - 2368:2368
  env_file:
    - ./config.env
  volumes:
    - "./petemsGhost/content/themes:/usr/src/ghost/content/themes"
    - "./petemsGhost/content/apps:/usr/src/ghost/content/apps"
    - "./petemsGhost/content/images:/usr/src/ghost/content/images"
    - "./petemsGhost/content/data:/usr/src/ghost/content/data"
    - "./petemsGhost/config:/var/lib/ghost"

我将它链接到代理容器请求的nginx容器:

ghost_nginx:
  restart: always
  build: ./ghostNginx/
  ports:
    - 80:80
    - 443:443
  links:
    - 'ghostblog:ghostblog'

在该构建中,我复制了一堆东西,密钥,配置等:

Dockerfile

FROM centos:centos6
# Delete defaults
RUN yum install epel-release -y
RUN yum install -y nginx curl
RUN rm /etc/nginx/nginx.conf
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/nginx.conf
COPY sites-enabled/petersouter.co.uk.conf /etc/nginx/sites-available/petersouter.co.uk.conf
COPY conf.d/ghost_blog_petersouter.co.uk-upstream.conf /etc/nginx/conf.d/ghost_blog_petersouter.co.uk-upstream.conf
COPY petersouter.co.uk.crt /etc/nginx/petersouter.co.uk.crt
COPY petersouter.co.uk.key /etc/nginx/petersouter.co.uk.key

EXPOSE 80 443

CMD ["nginx", "-g", "daemon off;"]

/etc/nginx/conf.d/ghost_blog_petersouter.co.uk-upstream.conf

upstream ghost_blog_petersouter.co.uk {
  server     ghostblog:2368  fail_timeout=10s;
}

/etc/nginx/sites-enabled/petersouter.co.uk.conf

# Redirect all non-SSL to SSL
server {
  listen         0.0.0.0:80;
  return         301 https://$server_name$request_uri;
}

# Main SSL Config Block
server {
  listen         0.0.0.0:443 ssl;

  ssl on;

  ssl_certificate           /etc/nginx/petersouter.co.uk.crt;
  ssl_certificate_key       /etc/nginx/petersouter.co.uk.key;
  ssl_session_cache         shared:SSL:10m;
  ssl_session_timeout       5m;
  ssl_protocols             TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers               ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA;
  ssl_prefer_server_ciphers on;

  index  index.html index.htm index.php;

  access_log            /var/log/nginx/ssl-petersouter.co.uk.access.log combined;
  error_log             /var/log/nginx/ssl-petersouter.co.uk.error.log;

  location / {
    proxy_pass            http://ghost_blog_petersouter.co.uk;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_buffering off;
  }

}

链接正常,因为我可以在nginx容器中看到它:

 $ docker exec -i -t petersouterblogcompose_ghost_nginx_1 bash
 $ curl ghostblog:2368
 $ Moved Permanently. Redirecting to https://petersouter.co.uk/

在容器之外,我可以直接卷曲ghost实例:

 $ curl 0.0.0.0:2368
 $ Moved Permanently. Redirecting to https://petersouter.co.uk/

但是当我尝试去80端口重定向时,我没有得到回应:

$ curl curl 0.0.0.0:80
$ curl: (52) Empty reply from server

我猜测我在某个地方的nginx配置中搞砸了一些东西,因为其他一切似乎都按预期工作了。

1 个答案:

答案 0 :(得分:3)

解决了它,它始终是简单的事情!

注意nginx Dockerfile的这一行:

sites-available

我正在复制到COPY sites-enabled/petersouter.co.uk.conf /etc/nginx/sites-enabled/petersouter.co.uk.conf 文件夹,因此conf永远不会被加载!修正了:

{{1}}

一切正常! :)