Accessing local Corteza install across LAN

Hello all,

New to Corteza, not super new to docker, I digress I am currently working on spinning up a docker container for a PoC for our internal team who would then present findings and work to a potential customer.

I was able to spin up the docker container locally on a Win10 VDI using Docker for Windows. I installed and ran the container using this tutorial. The containers were pulled down and I was able to run them. Then I was able to access the web GUI navigating to localhost:18080 and 127.0.0.1:18080 and login and setup users. No issues.

However I am running into issues with trying to access the local environment from across our LAN. I tried accessing the web GUI from my local laptop (obviously separate from the VDI). I get a timeout or connection reset. I have disabled both the AV host-based firewall and the dedicated Windows firewall as well but I am still not able to get to the web GUI. To troubleshoot further, I pulled down and ran portainer and was able to access its web GUI from across my LAN. So I know its possible for this VDI.

Any ideas why? I thought I read somewhere in the documentation that you needed to do some special configuration for exposing the local install to you greater LAN but I cannot for the life of me find it.

Here is my docker .env file and the docker-compose.yml file.

.env -

########################################################################################################################
# docker-compose supports environment variable interpolation/substitution in compose configuration file
# (more info: https://docs.docker.com/compose/environment-variables)

########################################################################################################################
# General settings
DOMAIN=localhost:18080
VERSION=2021.9.7

########################################################################################################################
# Database connection
DB_DSN=dbuser:dbpass@tcp(db:3306)/dbname?collation=utf8mb4_general_ci

########################################################################################################################
# Server settings

# Running all-in-one and serving web applications directly from server container
HTTP_WEBAPP_ENABLED=true

# Disabled, we do not need detailed persistent logging of actions in local env
ACTIONLOG_ENABLED=false

########################################################################################################################
# SMTP (mail sending) settings

# Point this to your local or external SMTP server if you want to send emails.
# In most cases, Corteza can detect that SMTP is disabled and skips over sending emails without an error
#SMTP_HOST=smtp-server.example.tld:587
#SMTP_USER=postmaster@smtp-server.example.tld
#SMTP_PASS=this-is-your-smtp-password
#SMTP_FROM='"Demo" <info@your-demo.example.tld>'

And the docker-compose.yml -

version: '3.5'

services:
  server:
    image: cortezaproject/corteza:${VERSION}
    restart: always
    env_file: [ .env ]
    depends_on: [ db ]
    volumes:
      - "serverdata:/data"
    ports: ["127.0.0.1:18080:80" ]

  db:
    # MySQL Database
    # See https://hub.docker.com/r/percona/percona-server for details
    image: percona:8.0
    restart: always
    volumes:
      - "dbdata:/var/lib/mysql"
    environment:
      MYSQL_DATABASE: dbname
      MYSQL_USER:     dbuser
      MYSQL_PASSWORD: dbpass
      # get the random generated password by running: docker-compose logs db | grep "GENERATED ROOT PASSWORD"
      MYSQL_RANDOM_ROOT_PASSWORD: random
    healthcheck: { test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"], timeout: 20s, retries: 10 }

volumes:
  dbdata:
  serverdata:

Any help would be truly appreciated.

You’re binding containers ports on localhost – and you can only access it from your machine.

What you should do (never did anything with docker on a windows machine, so good luck)
Change the ports settings and remove the ip (127.0.0.1) and rebuild your containers with docker-compose up -d.

Should look something like 0.0.0.0:18080->80/tcp when you run docker ps.

If you do not have any fancy firewall this should work without much problems.

BTW – if you do not have anything else running on port 80, feel free to change port 18080 to 80 and remove it in the .env file from the DOMAIN setting.

In the .env file you’ll probably have to change “localhost” with your IP address you are using to connect to from other boxes.

:crossed_fingers:

1 Like

:man_facepalming:I even tried mapping it to the specific IP address and could not get it work. But I did not change the .env file. So that might have been why.

I just changed the compose file to the specific IP address and removed the DOMAIN=localhost:18080 from the .env file.
Here are the new parts of the both files:

########################################################################################################################
# General settings
VERSION=2021.9.7

And now the docker-compose.yml:

version: '3.5'

services:
  server:
    image: cortezaproject/corteza:${VERSION}
    restart: always
    env_file: [ .env ]
    depends_on: [ db ]
    volumes:
      - "serverdata:/data"
    ports: ["0.0.0.0:18080:80" ]

Re-ran docker-compuse up -d. Getting a different error this time when trying access the web GUI. It looks like my browser is trying to redirect to:

http://70f41e10a292/auth/oauth2/default-client?redirect_uri=http://10.252.0.118:18080/auth/callback&scope=profile%20api&state=zsragxz8r6i

Even when I specify the IP address and port.

Any other ideas?

1 Like

Figured it out. I set the IP address in both the docker-compose.yml and I forgot to hardcode it in the .env file. Did both, re-ran docker-compose up -d and it worked without issue.

Here are my configs:
The .env file -

########################################################################################################################
# General settings
DOMAIN=10.252.0.118:18080
VERSION=2021.9.7

docker-compose.yml -

version: '3.5'

services:
  server:
    image: cortezaproject/corteza:${VERSION}
    restart: always
    env_file: [ .env ]
    depends_on: [ db ]
    volumes:
      - "serverdata:/data"
    ports: ["10.252.0.118:18080:80" ]

Thanks!

2 Likes

Congrats! :slight_smile:

You must provide the domain name otherwise Corteza tries to get something from the environment and it usually ends up with machine (container) hostname. In your (previous) case - 70f41e10a292 . That is probably container ID.