- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在通过提供的 docker 容器 (https://datajoint.github.io/datajoint-labbook/user.html#installation) 运行 Datajoint LabBook,想知道是否有办法将它从(默认?)端口(80?)移开。我不确定我是否理解 .yaml (docker-compose-deploy.yaml) 中的说明,在我看来有一个 pharus 端点 (5000),然后有两个端口定义(443:443、80:80 ) 再向下。我不确定这些指的是什么。
最佳答案
是的,您可以将 DataJoint LabBook 服务移动到不同的端口,但是,需要进行一些更改才能使其正常运行。
假设您正在本地访问 DataJoint LabBook,请按照以下步骤操作:
127.0.0.1 fakeservices.datajoint.io
添加到您的 hosts
文件。验证 hosts
文件 location in your file system .docker-compose-deploy.yaml
中的ports
配置为:ports:
- "3000:443" # replace 3000 with the port of your choosing
#- "80:80" # disables HTTP -> HTTPS redirect
https://fakeservices.datajoint.io:3000
让我先简单介绍一下架构,然后描述我们进行过程中的相关变化。
下面是Docker Compose file在文档中介绍。我假设您正在尝试在本地运行它。
# 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:
首先,上面标题注释中的注意
很重要,DataJoint LabBook 文档中似乎遗漏了它(我已将此 issue 归档以对其进行更新)。确保遵循 Note
中的说明,因为“安全”访问是 required from pharus (更多内容见下文)。
从 Docker Compose 文件中,您会注意到 2 个服务:
pharus
- DataJoint REST API 后端服务。此服务配置为监听端口 5000
,但实际上并未向主机公开。这意味着它不会冲突并且不需要任何更改,因为它完全包含在本地虚拟 docker 网络中。
fakeservices.datajoint.io
- 向主机公开的代理服务,因此可以在本地和主机上公开访问。它的主要目的是:
a) 将以/api
开头的请求转发给pharus
,或者
b) 解决对 DataJoint LabBook GUI 的其他请求。
DataJoint LabBook 的 GUI 是一个静态网络应用程序,这意味着它可以作为不安全(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
来确认端口更改。
关于Datajoint LabBook - 如何更改端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66929590/
我正在通过提供的 docker 容器 (https://datajoint.github.io/datajoint-labbook/user.html#installation) 运行 Datajoi
我是一名优秀的程序员,十分优秀!