koken / docker-koken-lemp

Docker image for Koken. Uses Ubuntu, nginx, MySQL, and PHP 5.
MIT License
101 stars 43 forks source link

API Error - docker-compose #12

Open jujes opened 8 years ago

jujes commented 8 years ago

koken-issue

API Error

The theme is not able to make contact with your Koken installation. Contact your host to see if they are blocking loopback connections.

proxy script

docker run -d -p 80:80 -p 443:443 -v /etc/nginx/certs:/etc/nginx/certs -v /var/run/docker.sock:/tmp/docker.sock:ro --name=proxy --restart=always jwilder/nginx-proxy

docker-compose.yml

koken:
  restart: always
  image: koken/koken-lemp
  container_name: koken.dev
  environment:
    - VIRTUAL_HOST=koken.dev
  volumes:
    - /home/vagrant/dpl/koken.dev/src/www:/usr/share/nginx/www
    - /home/vagrant/dpl/koken.dev/src/mysql/:/var/lib/mysql

someone know how fix it?

simonsmiley commented 8 years ago

I can't get it to work either. My file looks like this:

koken:
  image: 'koken/koken-lemp'
  restart: always
  hostname: koken.example.com
  ports:
    - '8080:80'
  environment:
    - VIRTUAL_HOST=koken.example.com
  volumes:
    - './koken/data:/usr/share/nginx/www'
    - './koken/db:/var/lib/mysql'
Removed-5an commented 8 years ago

Log in to the admin interface, download a theme and make sure to configure your site to use that theme.

simonsmiley commented 8 years ago

@5an1ty downloaded an additional theme, but I can't change the settings so that koken uses it. Do you also use a docker installation with port forwarding?

Removed-5an commented 8 years ago

Yes, installed it regularly, I recall having a similar theme error, opened up the admin interface on yourip/admin and modified the theme settings there.

You have to go to the site section, then click on the themes button at the bottom of the page and activate the theme you selected. (I tried the theme elementary)

Not sure what this env variable does, don't think I set it: VIRTUAL_HOST=koken.example.com

darklow commented 7 years ago

I was able to fix this problem by modifying user_setup.php and adding following line:

define('LOOPBACK_HOST_HEADER', true);

For new build change file deploy/php/user_setup.php For already deployed app file is under storage/configuration/

jujes commented 7 years ago

@darklow your advice don't solve my fix.... someone know how fix it?

thanks in advance...

I use https

version: '2'

services:
  web:
    image: jujes/koken:0.22.23
    hostname: koken.dev
#    volumes:
#      - $HOME/.docker/koken/html:/var/www/html
    networks:
      - docker_webgateway
      - back
    environment:
      - VIRTUAL_HOST=koken.dev
    labels:
      - "traefik.domain=koken.dev"
      - "traefik.enable=true"
      - "traefik.backend=koken.dev"
      - "traefik.frontend.rule=Host:koken.dev"
      - "traefik.docker.network=docker_webgateway"
      - "traefik.port=80"
    links:
      - db

  db:
    image: mysql:latest
    environment:
      - MYSQL_DATABASE=koken
      - MYSQL_USER=koken
      - MYSQL_PASSWORD=demo0909809
      - MYSQL_ROOT_PASSWORD=demodododo
#    volumes:
#      - $HOME/.docker/koken/mysql:/var/lib/mysql
    networks:
      - back
    restart: always
    labels:
      - "traefik.enable=false"

networks:
  docker_webgateway:
    external:
      name: docker_webgateway
  back:
    driver: bridge
helderco commented 7 years ago

If you're running in your own machine (i.e., not a public URL), your koken container needs to access your host.

Try adding:

web:
  extra_hosts:
    - koken.dev: 10.254.254.254

Replace 10.254.254.254 with your host's IP, but you might want to make an alias so it's always available independently from your network.

sudo ifconfig en0 alias 10.254.254.254 255.255.255.0 

Note: find your network interface, it might not be eth0.

This works for me.

georgako commented 7 years ago

I was facing the same issue while using the guide for Installing Koken to Digital Ocean droplet (via docker). The installation page was hanging. I added in user_setup.php:

define('LOOPBACK_HOST_HEADER', true);

under storage/configuration/

No need for any process restart, just refresh your browser. Your fresh new koken is there. It took me 1 week searching on web about this.

Thanks @darklow for sharing!

pspoerri commented 6 years ago

I had a similar issue even with define('LOOPBACK_HOST_HEADER', true); when I had another host terminate the SSL connection:

               +--------------------------+
               |                          |
               | Docker Host              |
  HTTPS        | +----------------------+ |
+------------->+ |                      | |
               | | NGINX Reverse Proxy  | |
  HTTP         | |                      | |
+------------->+ |                      | |
               | +--+-------------------+ |
               |    |                     |
               |    | HTTP Connection     |
               |    |                     |
               | +--v-------------------+ |
               | |                      | |
               | |  Koken Host          | |
               | |                      | |
               | |                      | |
               | +----------------------+ |
               +--------------------------+

If you have this problem then you will probably see weird characters in the koken apache/nginx log: \x16\x03\x01\x02. The problem is that Koken determines the protocol it should use based on the web protocol used on the SSL-terminating proxy. One option is to hack app/site/Koken.php with the solution shown here - which is not sustainable if you wonder why your koken does not run after an update.

I managed to get around this by enabling SSL in the Dockerfile:

# Enable SSL for loopback connections
RUN a2ensite default-ssl
RUN a2enmod ssl
RUN make-ssl-cert generate-default-snakeoil --force-overwrite 
EXPOSE 443

and exposing the koken host as an extra_hosts in the docker compose:

        extra_hosts:
          - ${DOMAIN}:127.0.0.1

Dockerfile and docker-compose.yml as a reference. If you are interested in my setup I have it here: https://github.com/pspoerri/docker-koken-letsencrypt (I still need to document and test it properly).

darklow commented 5 years ago

This is getting even more weird, under different server and different docker setup using docker-compose.yml in order to fix this issue I needed to do exact opposite - remove this line which I added to for previous setup to work define('LOOPBACK_HOST_HEADER', true);