Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traefik integration #13

Closed
yahya077 opened this issue Dec 8, 2021 · 16 comments
Closed

Traefik integration #13

yahya077 opened this issue Dec 8, 2021 · 16 comments

Comments

@yahya077
Copy link

yahya077 commented Dec 8, 2021

How can we use with traefik reverse proxy

I'm using all of my apps with Traefik. I setup my docker compose file but it didn't worked for espocrm docker-compose.yml file.
So if I missed anything can you guys help me out.
My docker-compose.yml file down below.
`
version: '3.8'

services:

mysql:
image: mysql:8
container_name: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: espocrm
MYSQL_USER: espocrm
MYSQL_PASSWORD: database_password
command: --default-authentication-plugin=mysql_native_password
networks:
- espocrm
volumes:
- /storage/espocrm/mysql:/var/lib/mysql
labels:
- "traefik.enable=false"

espocrm:
image: espocrm/espocrm
container_name: espocrm
environment:
ESPOCRM_DATABASE_HOST: mysql
ESPOCRM_DATABASE_USER: espocrm
ESPOCRM_DATABASE_PASSWORD: database_password
ESPOCRM_ADMIN_USERNAME: admin
ESPOCRM_ADMIN_PASSWORD: password
ESPOCRM_SITE_URL: "https://espocrm.mydomain.com"
networks:
- espocrm
- proxy
volumes:
- /storage/espocrm:/var/www/html
labels:
- "traefik.enable=true"
- "traefik.http.routers.espocrm.rule=Host(espocrm.mydomain.com)"
- "traefik.http.services.espocrm.loadbalancer.server.port=8080"
- "traefik.http.routers.espocrm.entrypoints=websecure"
- "traefik.http.routers.espocrm.tls=true"
- "traefik.http.routers.espocrm.tls.certresolver=cloudflare"
- "traefik.http.routers.espocrm.tls.domains[0].main=espocrm.mydomain.com"
restart: always
expose:
- 8080

espocrm-daemon:
image: espocrm/espocrm
container_name: espocrm-daemon
networks:
- espocrm
volumes:
- /storage/espocrm:/var/www/html
restart: always
entrypoint: docker-daemon.sh

espocrm-websocket:
image: espocrm/espocrm
container_name: espocrm-websocket
environment:
ESPOCRM_CONFIG_USE_WEB_SOCKET: "true"
ESPOCRM_CONFIG_WEB_SOCKET_URL: "ws://espocrm.mydomain.com"
ESPOCRM_CONFIG_WEB_SOCKET_ZERO_M_Q_SUBSCRIBER_DSN: "tcp://*:7777"
ESPOCRM_CONFIG_WEB_SOCKET_ZERO_M_Q_SUBMISSION_DSN: "tcp://espocrm-websocket:7777"
volumes:
- /storage/espocrm:/var/www/html
networks:
- espocrm
restart: always
entrypoint: docker-websocket.sh
expose:
- 8081
- 7777

networks:
espocrm:
driver: bridge
proxy:
external:
name: "traefik_proxy"

volumes:
mysql:
espocrm:

`

@tmachyshyn tmachyshyn transferred this issue from espocrm/espocrm Dec 9, 2021
@tmachyshyn
Copy link
Collaborator

Please check if you have specified traefik.docker.network: proxy.
What error do you have in traefik dashboard?

@yahya077
Copy link
Author

yahya077 commented Dec 9, 2021

Thank you for your response. There is no error either traefik and docker-compose log. I connect to the container and checked to the apache server status and it is working. I couldn't find a problem to solve because I couldn't see an error message. Where am I doing wrong? I can serve on ip without using traefik, but I want to serve over domain with traefik

@tmachyshyn
Copy link
Collaborator

You can try to mount the /etc/apache2/sites-available/000-default.conf where define your domain name espocrm.mydomain.com.

@yahya077
Copy link
Author

yahya077 commented Dec 10, 2021

My /etc/apache2/sites-available/000-default.conf file. After I update the file I reload the apache server and it still doesn't work.

<VirtualHost *:80>
	ServerName espocrm.mydomain.com

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

@tmachyshyn
Copy link
Collaborator

This container of EspoCRM uses the php-apache image. Do you any other containers with the apache and PHP?

@yahya077
Copy link
Author

If you mean in that server has any container of apache server it doesn’t.

@tmachyshyn
Copy link
Collaborator

tmachyshyn commented Dec 14, 2021

Ok, thanks.

Here is EspoCRM an example for traefik v1 with let's encrypt:

version: '3'

networks:
  http_network:
    external: true
  internal_network:
    external: false

services:

  espocrm.domain.com:
    container_name: "espocrm.domain.com"
    image: espocrm/espocrm:latest    
    volumes:
      - ./espocrm/html:/var/www/html
      - ./espocrm/logs:/var/log/apache2
    restart: always
    labels:
      - traefik.enable=true
      - traefik.frontend.rule=Host:espocrm.domain.com
      - traefik.docker.network=http_network
      - traefik.frontend.redirect.entryPoint=https
    depends_on:
      - traefik
      - mysqlserver
    networks:
      - internal_network
      - http_network

@yahya077
Copy link
Author

yahya077 commented Dec 18, 2021

The sample you sent is not possible to work even in theory. Where is the environments even if it is using default variable where do you put the domain in Apache Server. If you do not specify the domain name it will throw error like 'Set the 'ServerName' directive globally to suppress this message'. The only docker image that I can not run with traefik. I put so much effort to figure out how the espocrm server work but I didn't find yet.

@tmachyshyn
Copy link
Collaborator

I'm very busy right now. I will try to create a configuration for Traefik v2 in 2 weeks and let you know.

@yahya077
Copy link
Author

Thank you for your response. I’m waiting for it.

@sekjal
Copy link

sekjal commented Mar 11, 2022

I'm taking a look at this now, and will post any solutions I come up with (or if y'all have already got this configured, I'd be happy to see it!)

@yahya077
Copy link
Author

Sorry, still is an issue :/ .

@FabPari
Copy link

FabPari commented Apr 6, 2022

Hi, no one has a solution for Espo behind Traefik?
Possibly install 2 different Espocrm and point 2 different IPs and use the same mysql?

@arkadiyasuratov
Copy link

I managed to make it work with Traefik.

$ docker -v
Docker version 20.10.13, build a224086
$ docker-compose -v
docker-compose version 1.29.2, build unknown
$ docker exec -it traefik traefik version
Version:      2.5.4
Codename:     livarot
Go version:   go1.17.3
Built:        2021-11-08T17:41:41Z
OS/Arch:      linux/amd64

Usage with Traefik

---
version: '3.8'

services:

  mysql:
    image: mysql:8
    container_name: mysql
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_ROOT_PASSWORD: root_password
      MYSQL_DATABASE: espocrm
      MYSQL_USER: espocrm
      MYSQL_PASSWORD: database_password
    volumes:
      - mysql:/var/lib/mysql
    restart: always

  espocrm:
    image: espocrm/espocrm
    container_name: espocrm
    environment:
      ESPOCRM_DATABASE_HOST: mysql
      ESPOCRM_DATABASE_USER: espocrm
      ESPOCRM_DATABASE_PASSWORD: database_password
      ESPOCRM_ADMIN_USERNAME: admin
      ESPOCRM_ADMIN_PASSWORD: password
      ESPOCRM_SITE_URL: "https://${DOMAIN}"
    volumes:
      - espocrm:/var/www/html
    restart: always
    labels:
      - traefik.enable=true
      - traefik.docker.network=traefik_public
      - traefik.http.routers.espocrm-app.rule=Host(`${DOMAIN}`)
      - traefik.http.routers.espocrm-app.entrypoints=https
      - traefik.http.routers.espocrm-app.tls=true
      - traefik.http.routers.espocrm-app.tls.certresolver=letsencrypt

  espocrm-daemon:
    image: espocrm/espocrm
    container_name: espocrm-daemon
    volumes:
      - espocrm:/var/www/html
    restart: always
    entrypoint: docker-daemon.sh

  espocrm-websocket:
    image: espocrm/espocrm
    container_name: espocrm-websocket
    environment:
      ESPOCRM_CONFIG_USE_WEB_SOCKET: "true"
      ESPOCRM_CONFIG_WEB_SOCKET_URL: "wss://${DOMAIN}/ws"
      ESPOCRM_CONFIG_WEB_SOCKET_ZERO_M_Q_SUBSCRIBER_DSN: "tcp://*:7777"
      ESPOCRM_CONFIG_WEB_SOCKET_ZERO_M_Q_SUBMISSION_DSN: "tcp://espocrm-websocket:7777"
    volumes:
      - espocrm:/var/www/html
    restart: always
    entrypoint: docker-websocket.sh
    labels:
      - traefik.enable=true
      - traefik.docker.network=traefik_public
      - traefik.http.routers.espocrm-ws.rule=Host(`${DOMAIN}`) && PathPrefix(`/ws`)
      - traefik.http.routers.espocrm-ws.entrypoints=https
      - traefik.http.routers.espocrm-ws.tls=true
      - traefik.http.routers.espocrm-ws.tls.certresolver=letsencrypt
      - traefik.http.routers.espocrm-ws.service=espocrm-ws-service
      - traefik.http.services.espocrm-ws-service.loadbalancer.server.port=8080

volumes:
  mysql:
  espocrm:

networks:
  default:
    name: traefik_public
    external: true

@yahya077
Copy link
Author

yahya077 commented Apr 7, 2022

Well, it worked like a charm. Thank you so much. I just change a little. I made mysql internal cause I have more than one mysql in my server.

For mysql:

    networks:
      - proxy

For espocrm

    networks:
      - espocrm
      - proxy

And I removed this line
- traefik.docker.network=traefik_public

@yahya077 yahya077 closed this as completed Apr 7, 2022
@FabPari
Copy link

FabPari commented Apr 8, 2022

@arkadywtf you are my good! 2 days I try to make somethink like this
I test your file with portainer stack and it work! this i a great solution.
I have last request , do you think is possible install 2 different espocrm (2 completly different installation for 2 different company with other 2 domain) that have same mysql and add phpmyadmin?
Another possibility is create another stack like this one (tomorrow I'll test)
Thanks too much
Fabio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants