epam / ketcher

Web-based molecule sketcher
https://lifescience.opensource.epam.com/ketcher/demo.html
Apache License 2.0
470 stars 165 forks source link

Direct reverse proxying with Traefik without Nginx for Ketcher deployment #2688

Open xaya1001 opened 1 year ago

xaya1001 commented 1 year ago

Background Hello, I have successfully deployed Ketcher using an Internet-Traefik-Nginx-Indigo stack with the following configuration:

services:
  nginx:
    image: nginx:1.25.0-alpine
    container_name: nginx
    restart: always
    volumes:
      - ~/ketcher/nginx/conf.d:/etc/nginx/conf.d:ro
      - ~/ketcher/remote:/srv/www:ro
    labels:
      - traefik.enable=true
      - traefik.http.routers.ketcher.entryPoints=websecure
      - traefik.http.routers.ketcher.rule=Host(`chem.domian.com`)
      - traefik.http.routers.ketcher.service=ketcher
      - traefik.http.services.ketcher.loadbalancer.server.port=80
    networks:
      - traefik

  indigo:
    image: epmlsop/indigo_service
    container_name: indigo
    restart: always
    environment:
      - PYTHONPATH=${INDIGO_SERVICE_PYTHONPATH:-/srv/indigo-python}
      - INDIGO_UWSGI_RUN_PARAMETERS=--plugin python3 --py-autoreload=1
      - PYTHONDONTWRITEBYTECODE=1
    ports:
      - 8002:8002
    command: supervisord -n
    networks:
      - traefik

networks:
  traefik:
    external: true
server {
  listen 80;
  keepalive_timeout 5;

  location / {
    root /srv/www;
    index index.html;
    try_files $uri $uri/ @indigoservice;
  }

  location @indigoservice {

    add_header 'Access-Control-Allow-Origin' '*' always;
    add_header 'Access-Control-Allow-Methods' 'POST, GET, PUT, DELETE, OPTIONS' always;
    add_header 'Access-Control-Allow-Headers' 'Accept, Content-Type' always;
    add_header 'Access-Control-Max-Age' '86400' always;
    include uwsgi_params;
    uwsgi_pass indigo:8002;
  }
}

Solution

This setup allows me to directly access Ketcher via chem.domian.com. However, I am wondering if there is a way to eliminate Nginx from this stack and use Traefik as the direct reverse proxy instead.

Any guidance or suggestions on how this might be possible would be greatly appreciated. Thank you for your time and assistance.

xaya1001 commented 1 year ago

I just notice the name of the docker image I used above is epmlsop/indigo_service:latest which was created 5 years ago.

curl -X GET 'http://localhost:8080/v2/indigo/info'
{
  "Indigo": {
    "version": "1.3.0beta.r355-g4846731c linux64"
  }
}

The latest image name of indigo service is epmlsop/indigo-service:latest and the lastest official release version is epmlsop/indigo-service:1.10.0

Below is my update configuration:

services:
  nginx:
    image: nginx:1.25.0-alpine
    container_name: nginx
    restart: always
    volumes:
      - ~/ketcher/nginx/conf.d:/etc/nginx/conf.d:ro
      - ~/ketcher/remote:/srv/www:ro       # you should download latest ketcher-remote-2.9.0.zip and unzip into ~/ketcher/remote
    labels:
      - traefik.enable=true
      - traefik.http.routers.ketcher.entryPoints=websecure
      - traefik.http.routers.ketcher.rule=Host(`chem.domain.com`)
      - traefik.http.routers.ketcher.service=ketcher
      - traefik.http.services.ketcher.loadbalancer.server.port=80
    networks:
      - traefik

  indigo:
    image: epmlsop/indigo-service:latest   # or you can use: image: epmlsop/indigo-service:1.10.0
    container_name: indigo
    restart: always
    networks:
      - traefik

networks:
  traefik:
    external: true
server {
  listen 80;
  keepalive_timeout 5;

  location / {
    root /srv/www;
    index index.html;
    try_files $uri $uri/ @indigoservice;
  }

  location @indigoservice {

    add_header 'Access-Control-Allow-Origin' '*' always;
    add_header 'Access-Control-Allow-Methods' 'POST, GET, PUT, DELETE, OPTIONS' always;
    add_header 'Access-Control-Allow-Headers' 'Accept, Content-Type' always;
    add_header 'Access-Control-Max-Age' '86400' always;
    proxy_pass http://indigo:80;
  }
}
docker exec nginx curl -s http://indigo:80/v2/info
{"imago_versions":["2.0.0"],"indigo_version":"1.12.0-rc.1.0-gc9f696226-x86_64-linux-gnu-11.2.1"}