繁体   English   中英

Datajoint LabBook - 如何更改端口

[英]Datajoint LabBook - how to change ports

I am running Datajoint LabBook through the provided docker container ( https://datajoint.github.io/datajoint-labbook/user.html#installation ) and wondered whether there is a way to move it away from the (default?) port ( 80?)。 我不确定我是否理解.yaml(docker-compose-deploy.yaml)中的说明,在我看来,有一个pharus端点(5000)然后有两个端口定义(443:443、80:80 ) 再向下。 我不确定那些指的是什么。

是的,您可以将 DataJoint LabBook 服务移动到不同的端口,但是,需要对其进行一些更改才能正确地更改为 function。

TL;博士

假设您在本地访问 DataJoint LabBook,请执行以下步骤:

  1. 将行127.0.0.1 fakeservices.datajoint.io添加到您的hosts文件中。 验证文件系统中的hosts文件位置
  2. 修改docker-compose-deploy.yaml中的ports配置为:
ports:
  - "3000:443" # replace 3000 with the port of your choosing
  #- "80:80" # disables HTTP -> HTTPS redirect
  1. 在您的 Google Chrome 浏览器中导航到https://fakeservices.datajoint.io:3000

详细说明

让我先谈谈架构,然后描述一下我们 go 的相关变化。

以下是文档中提供的Docker Compose 文件 我会假设您正在尝试在本地运行它。

# PHARUS_VERSION=0.1.0 DJLABBOOK_VERSION=0.1.0 docker-compose -f docker-compose-deploy.yaml pull
# PHARUS_VERSION=0.1.0 DJLABBOOK_VERSION=0.1.0 docker-compose -f docker-compose-deploy.yaml up -d
#
# Intended for production deployment.
# Note: You must run both commands above for minimal outage.
# Make sure to add an entry into your /etc/hosts file as `127.0.0.1 fakeservices.datajoint.io`
# This serves as an alias for the domain to resolve locally.
# With this config and the configuration below in NGINX, you should be able to verify it is
# running properly by navigating in your browser to `https://fakeservices.datajoint.io`.
# If you don't update your hosts file, you will still have access at `https://localhost`
# however it should simply display 'Not secure' since the cert will be invalid.
version: "2.4"
x-net: &net
  networks:
      - main
services:
  pharus:
    <<: *net
    image: datajoint/pharus:${PHARUS_VERSION}
    environment:
      - PHARUS_PORT=5000
  fakeservices.datajoint.io:
    <<: *net
    image: datajoint/nginx:v0.0.16
    environment:
      - ADD_zlabbook_TYPE=STATIC
      - ADD_zlabbook_PREFIX=/
      - ADD_pharus_TYPE=REST
      - ADD_pharus_ENDPOINT=pharus:5000
      - ADD_pharus_PREFIX=/api
      - HTTPS_PASSTHRU=TRUE
    entrypoint: sh
    command:
      - -c
      - |
        rm -R /usr/share/nginx/html
        curl -L $$(echo "https://github.com/datajoint/datajoint-labbook/releases/download/\
            ${DJLABBOOK_VERSION}/static-djlabbook-${DJLABBOOK_VERSION}.zip" | tr -d '\n' | \
            tr -d '\t') -o static.zip
        unzip static.zip -d /usr/share/nginx
        mv /usr/share/nginx/build /usr/share/nginx/html
        rm static.zip
        /entrypoint.sh
    ports:
      - "443:443"
      - "80:80"
    depends_on:
      pharus:
        condition: service_healthy
networks:
  main:

首先,上面 header 评论中的Note很重要,似乎在 DataJoint LabBook 文档中被遗漏了(我已提交此问题以更新它)。 确保遵循注释中的Note ,因为需要从 pharus进行“安全”访问(更多内容见下文)。

从 Docker Compose 文件中,您会注意到 2 个服务:

  • pharus -DataJoint REST API 后端服务。 该服务被配置为侦听端口5000 ,但是,它实际上并未暴露给主机。 这意味着它不会发生冲突并且不需要任何更改,因为它完全包含在本地虚拟 docker 网络中。

  • fakeservices.datajoint.io - 向主机公开的代理服务,因此可以本地和公开访问主机。 其主要目的是:

    a) 将以/api开头的请求转发到pharus ,或

    b) 解决对 DataJoint LabBook GUI 的其他请求。

    DataJoint LabBook 的 GUI 是一个 static web 应用程序,这意味着它可以用作不安全(HTTP,通常是端口80 )和安全(HTTPS,通常是端口443 )。 由于pharus的安全要求,对端口80的请求被简单地重定向到443并为了方便而暴露。 因此,如果我们想将 DataJoint LabBook 移动到新端口,我们只需将443映射更改为主机上的新端口并禁用80 -> 443重定向。 因此,端口更新将如下所示:

ports:
  - "3000:443" # replace 3000 with the port of your choosing
  #- "80:80" # disables HTTP -> HTTPS redirect

最后,在配置和启动服务之后,您应该能够通过在 Google Chrome 浏览器中导航到https://fakerservices.datajoint.io:3000来确认端口更改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM