Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting async error #2

Open
frob opened this issue Oct 2, 2018 · 3 comments
Open

Getting async error #2

frob opened this issue Oct 2, 2018 · 3 comments

Comments

@frob
Copy link

frob commented Oct 2, 2018

I have canvas up and running and I am trying to add the RCE. Everything in canvas is working (seemingly) fine, but when I attempt to use RCE linking features I am getting this error in my browsers js console.

Failed to load http://rce.docker:3001/api/wikiPages?contextType=course&contextId=1: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://canvas.docker:3000' is therefore not allowed access. The response had HTTP status code 502. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I don't think this is a cors issue because I am getting this output form the RCE log.

canvas-rce_1  | App 39 output: [89892936-4cbb-4ad9-8169-787a675c1279] 127.0.0.1 - - [02/Oct/2018:21:06:43 +0000] "OPTIONS /api/wikiPages?contextType=course&contextId=1 HTTP/1.1" 204 - "http://canvas.docker:3000/courses/1/assignments/1/edit" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
canvas-rce_1  | 172.23.0.1 - - [02/Oct/2018:21:06:43 +0000] "OPTIONS /api/wikiPages?contextType=course&contextId=1 HTTP/1.1" 204 0 "http://canvas.docker:3000/courses/1/assignments/1/edit" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
canvas-rce_1  | App 39 output: (node:39) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'link' of undefined
canvas-rce_1  | App 39 output:     at parseBookmark (/usr/src/app/app/api/canvasProxy.js:32:35)
canvas-rce_1  | App 39 output:     at <anonymous>
canvas-rce_1  | App 39 output:     at process._tickCallback (internal/process/next_tick.js:188:7)
canvas-rce_1  | App 39 output: (node:39) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)

I probably have something misconfigured somewhere as I am just starting to get this settup, but I cannot determine from the above error what the missconfiguration is.

I am running the latest (as of 2nd Oct, 2018) RCE docker image. I am running everything locally with the intent of eventually running this in production. My docker-compose.yml is as follows.

version: '3'

services:
  # TODO use a custom redis based image that is a bit more hardedned.
  redis:
    image: redis:4.0-alpine
  # TODO use a custom postgres image that is a bit more hardened.
  db:
    image: postgres:9.5-alpine
    volumes:
      - ./tmp/db:/var/lib/postgresql/data
    # configure database access based on environment variables
    environment:
      - POSTGRES_USER=canvas
      - POSTGRES_PASSWORD=your_password
      - POSTGRES_DB=canvas,canvas_development,canvas_production,canvas_test

  canvas-lms: &LMS
    build:
      context: ./dockerfiles/canvas-lms
    command: bundle exec rails s -p 3000 -b '0.0.0.0'

    # which port should be accessible from the outside?
    ports:
      - "3000:3000"

    # start container once `db` service is up
    depends_on:
      - db
      - redis

    # `db` and `node` should be able to communicate
    links:
      - db
      - redis
      - canvas-rce

  # Delayed jobs
  jobs:
    <<: *LMS
    command: bundle exec script/delayed_job run
    links:
      - db
      - redis

    ports: []

  canvas-rce:
    image: instructure/canvas-rce-api:latest
    environment:
      - ECOSYSTEM_KEY
      - ECOSYSTEM_SECRET
      - FLICKR_API_KEY
      - YOUTUBE_API_KEY

    expose:
     - "80"

    ports:
      - "3001:80"

My canvas-lms dockerfile is simple enough, it sets up a production environment according to the prod documentation and copies in some custom configuration files. While it isn't based on the canvas-lms official docker image is accomplishes much the same thing.

I am running chrome, macos 10.13.6, Docker CE stable Version 18.06.1-ce-mac73 (26764)

@christopher-b
Copy link

I was seeing the same error when using the image from Docker Hub. At the moment, the "latest" image is 3 months old. Building the image from the repo resolved the error.

However, a new error surfaced: the app was unable to verify my Canvas instance cert. As a temporary workaround, I told node to not verify certs by setting NODE_TLS_REJECT_UNAUTHORIZED=0 in the container environment. Now to figure out how to tell node in a container to use the correct CA cert...

@srdurai
Copy link

srdurai commented Jan 14, 2019

Hi Christopher and Frob, Need help in setting process.env.NODE_TLS_REJECT_UNAUTHORIZED=0 setting in config.

I have canvas up and running with recent stable version from Jan'19. However, "Files" link under right side toolbox for course editing seems to be disabled. Found the following error while inspecting the source in browser: "Failed to load resource: net::ERR_NAME_NOT_RESOLVED
canvas-rce-api-host/api/folders?contextType=course&contextId=1:1"
and similar other errors. Though my docker image for canvas-rce-api was up and running with latest version, I didnt manage to do route the traffic through https on apache/nginx/HAProxy. Could you help me with some examples on how to set this process.env parameter? Other way around, to encrypt the traffic, some example apache conf file will do. Thanks already.

@christopher-b
Copy link

@srdurai Not sure if this is still relevant to you, but you can set this env var when you fire up your docker container:

docker run \
  -e ECOSYSTEM_KEY \
  -e ECOSYSTEM_SECRET \
  ...
  -e NODE_TLS_REJECT_UNAUTHORIZED=1 \
  instructure/canvas-rce-api

Instructure just pushed an updated image to Docker Hub, so the original problem mentioned in this ticket has been resolved. I'm still working on a solution to the TLS error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants