简体   繁体   中英

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?). I am not sure I understand the instructions in the.yaml (docker-compose-deploy.yaml), it seems to me that there is a pharus endpoint (5000) and then there are two port definitions (443:443, 80:80) further down. I am not sure what those refer to.

Yes, you can move the DataJoint LabBook service to a different port, however, a few changes will be necessary for it to function properly.

TL;DR

Assuming that you are accessing DataJoint LabBook locally, follow these steps:

  1. Add the line 127.0.0.1 fakeservices.datajoint.io to your hosts file. Verify the hosts file location in your file system .
  2. Modify the ports configuration in docker-compose-deploy.yaml as:
ports:
  - "3000:443" # replace 3000 with the port of your choosing
  #- "80:80" # disables HTTP -> HTTPS redirect
  1. Navigate in your Google Chrome browser to https://fakeservices.datajoint.io:3000

Detailed Explanation

Let me first speak a bit on the architecture and then describe the relevant changes as we go along.

Below is the Docker Compose file presented in the documentation. I'll make the assumption that you are attempting to run this locally.

# 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:

First, the Note in the header comment above is important and seems to have been missed in the DataJoint LabBook documentation (I've filed this issue to update it). Make sure to follow the instruction in the Note as 'secure' access is required from pharus (more on this below).

From the Docker Compose file, you will note 2 services:

  • pharus - A DataJoint REST API backend service. This service is configured to listen on port 5000 , however, it is not actually exposed to the host. This means that it will not conflict and does not require any change as it is entirely contained within a local, virtual docker network.

  • fakeservices.datajoint.io - A proxying service that is exposed to the host and thus accessible locally and publicly against the host. Its primary purpose is to either:

    a) forward requests beginning with /api to pharus , or

    b) resolve other requests to the DataJoint LabBook GUI.

    DataJoint LabBook's GUI is a static web app which means that it can be served as insecure (HTTP, typically port 80 ) and secure (HTTPS, typically port 443 ). Because of the secure requirement from pharus , requests made to port 80 are simply redirected to 443 and exposed for convenience. Therefore, if we want to move DataJoint LabBook to a new port we simply should change the mapping of 443 to a new port on the host and disable the 80 -> 443 redirect. Therefore, the port update would look like so:

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

Finally, after configuring and bringing up the services, you should be able to confirm the port change by navigating to https://fakerservices.datajoint.io:3000 in your Google Chrome browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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