A
A
Askhat Bikmetov2016-02-02 13:38:05
Nginx
Askhat Bikmetov, 2016-02-02 13:38:05

How to put ownCloud behind Nginx in Docker?

I need to access my ownCloud instance via Nginx, both of which are in separate Docker containers. I created docker-compose.yml :

nginx:
  image: nginx
  ports:
    - 80:80
  volumes:
    - ./nginx.conf:/etc/nginx/nginx.conf
  links:
    - owncloud
owncloud:
  image: owncloud
  ports:
    - 6789:80
  volumes:
    - ~/ownCloud:/var/www/html/data

And the corresponding nginx.conf for proxying requests:
http {
  server {
    listen 80 default;
    server_name docker.dev;

    location / {
      proxy_pass http://127.0.0.1:6789;
      proxy_buffering off;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
    }
  }
}
events {}

Everything seems to be correct, but Nginx logs the following when trying to access docker.dev
[error] 6#6: *8 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.99.1, server: docker.dev

What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Askhat Bikmetov, 2016-02-02
@askhat

The problem is that it proxy_pass http://127.0.0.1:6789;looks at its own container and not at the service owncloud. Fortunately , it docker-composeadds the addresses of services to /etc/hosts, which can be seen by running the command docker exec nginx cat /etc/hosts, there will be a line 172.17.0.2 owncloud 8a567934bb13.
So if you change docker-compose.yml, replacing ports: - 6789:80with expose: - 80, and nginx.conf, replacing the value proxy_passwith http://owncloud;- everything will work.

N
Nazar Mokrinsky, 2016-02-02
@nazarpc

Better take this one: https://github.com/nazar-pc/docker-webserver-apps/...
There, the update procedure is described (which you will have to do anyway), and everything is configured as expected (including LibreOffice for support for MS Office documents).
Based on https://github.com/nazar-pc/docker-webserver , which means there are ready-made backup and restore scripts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question