10

I'm a linux noob in admin of docker container using apache or nginx on VPS.

I use an OVH classic Vps (4go ram, 25Go SSD) with already installed image of ubuntu 15.04 + docker.

Install of docker container is really easy, and in my case i install without problem the image sharelatex.

docker run -d \
  -v ~/sharelatex_data:/var/lib/sharelatex \
  -p 5000:80 \
  --name=sharelatex \
  sharelatex/sharelatex

Site is accessible on IP of the VPS at http://51.255.47.40:5000 port show that site work without any problem.

I have already a sub domain (tools.sebastienreycoyrehourcq.fr) configurated to go on the server ip vps (51.255.47.40 routed to External in webfaction panel ), not working, don't understand why.

I install an apache server on 51.255.47.40, but i suppose the best option is probably to install a docker image of nginx or apache ? Can you advice me on this point ? And after that, how can i redirect to 5000 port of the docker image on a classic 80 port of apache or nginx linked to my subdomain ?

reyman64
  • 523
  • 4
  • 34
  • 73

3 Answers3

4

Previous answers probably covers most of the issues, especially if there were redirection problems of your domain name.

In order to be fully portable and use all the possibilities of docker, my recommendation would be to used the Nginx official docker image and make it the only one accessible from the outside (with the opening of ports) and use the --link to manage connectivity between your Nginx containers and your other containers.

I have done that in similar situation which works pretty well. Below is a tentative translation of what I have done to your situation.

You start your share latex container without specifying any external port :

docker run -d \
  -v ~/sharelatex_data:/var/lib/sharelatex \
  --name=sharelatex \
  sharelatex/sharelatex

You prepare an nginx conf file for your shareLatex server that you place in $HOME/nginx/conf that will look like

upstream sharelatex {
     # this will refer to the name you pass as link to the nginx container
     server sharelatex; 
}

server {
        listen 80;
        server_name tools.sebastienreycoyrehourcq.fr;
        location  ^~ / {
              proxy_pass http://sharelatex/;
        }
}

You then start your nginx docker container with the appropriate volume links and container links :

docker run -d --link sharelatex:sharelatex --name NginxMain -v $HOME/nginx/conf:/etc/nginx/sites-available -v -p 80:80 kekev76/nginx

ps : this has been done with our own kekev76/nginx image that is public on github and docker but you can adapt the principle to the official nginx image.

Yves Nicolas
  • 6,901
  • 7
  • 25
  • 40
2

nginx-proxy (https://github.com/jwilder/nginx-proxy) and then running sharelatex with VIRTUAL_HOST set to tools.sebastienreycoyrehourcq.fr should be enough to get this working.

e.g.

docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy

followed by

docker run -d \
-e VIRTUAL_HOST=tools.sebastienreycoyrehourcq.fr \
-v ~/sharelatex_data:/var/lib/sharelatex \
-p 5000:80 \
--name=sharelatex \
sharelatex/sharelatex
Tom Parker-Shemilt
  • 1,679
  • 15
  • 26
  • Thanks for answer, with nginx-proxy is it possible to save the generated config file in a volume ? – reyman64 Nov 18 '15 at 09:54
  • Based off of `https://github.com/jwilder/nginx-proxy/blob/master/Procfile`, `docker cp :/etc/nginx/conf.d/default.conf nginx.conf` should do it. – Tom Parker-Shemilt Nov 18 '15 at 11:08
2

The subdomain tools.sebastienreycoyrehourcq.fr is not configured properly. It does not resolve to any IP address which is the reason it does not work.

After you configure your subdomain, you can run the sharelatex container on port 80 with this command:

docker run -d \
  -v ~/sharelatex_data:/var/lib/sharelatex \
  -p 80:80 \
  --name=sharelatex \
  sharelatex/sharelatex

This way you can access the app at http://tools.sebastienreycoyrehourcq.fr

mike
  • 5,047
  • 2
  • 26
  • 32