faloker / purify

All-in-one tool for managing vulnerability reports from AppSec pipelines

Home Page:https://faloker.gitbook.io/purify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When using docker instance gives mongodb port connection error

zorianix opened this issue · comments

When executing docker instance mongodb connection refused error is throw.

Docker ps show mongodb port open

Hey @zorianix,

Can you check that you provide correct URI to connect to the MongoDB instance?

Config file(.env.example) used in docker-compose file:

api:
    image: faloker/purify-api
    restart: always
    env_file:
      - ./api/.env.example

Should have something like this:
MONGODB_URI=mongodb://root:example@mongo:27017

I got this running however i am only able to access this locally from the system on which the docker is running . I am running over vm and if I try accessing the ui , the ui gets loaded , however the login and signup features doesnt work

if I try accessing the ui , the ui gets loaded , however the login and signup features doesnt work

Can you share what errors you see when you try to login or register?

I only see error in the ui , stating "Signup/Login Failed" nothing else. Also the idea of letting the user select the content he wants to be displayed from an imported report is an awesome concept

If login or register is not working, then the console or network tab of a browser will contain some sort of errors. Could you reproduce the problem and attach these errors to this issue?

If i run this in prod mode i cannot access it either on localhost or remotely

with dev mode ,i can access via localhost , and cannot access it via ip remotely , only ui gets loaded.

ok then, could you try to update your setup in the following way:

  • checkout develop branch
  • edit docker-compose.yml
version: "2"

services:
  mongo:
    image: mongo
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example
    volumes:
      - mongo_db:/data/db

  api:
    build:
      context: .
      dockerfile: api.dockerfile
    restart: always
    env_file:
      - ./api/.env.example
    depends_on:
      - mongo
    environment:
      NODE_ENV: production

  nginx:
    image: faloker/purify-nginx
    restart: always
    volumes:
      - ./nginx/nginx.dev.conf:/etc/nginx/nginx.conf
    depends_on:
      - api
    ports:
      - 8080:8080

volumes:
  mongo_db: {}
  • edit nginx dev config (because it will be served over http)
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
  worker_connections 1024;
}

http {
  include /etc/nginx/mime.types;
  default_type application/octet-stream;
  log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';
  access_log /var/log/nginx/access.log main;
  client_max_body_size 800m;
  sendfile on;
  keepalive_timeout 65;

  server {
    listen 8080 default_server;
   
    # change to your VM IP address
    server_name 192.168.1.2;

    location / {
      root /app;
      index index.html;
      try_files $uri $uri/ /index.html;
    }

    location /api {
      proxy_pass http://api:3000;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
      root /usr/share/nginx/html;
    }
  }
}
  • edit .env file (.env.example in that case)
JWT_SECRET=changeme
MONGODB_URI=mongodb://root:example@mongo:27017
DB_NAME=purify
# the same VM IP
DOMAIN=192.168.1.2
SECURE=false
  • exec docker-compose up -d --build
  • on the host machine navigate to http://192.168.1.2:8080
  • everything should work