Internet facing IN v5 install (Docker)

Hey there,

I’ve been testing different accounting software for the last weeks, and decided to go with IN for the better features (Project/Expenses/Tasks).

I’ve followed the instructions to install the Docker container with Nginx as web server on my local server. Ideally, I’d like it to be only a local service, but I’m facing issues when generating the PDF from an invoice, as other reported. The process just gets stuck as shown in the image.

Now I’ve tried to set up the Docker to be exposed to the internet so I can use PhantomJS Cloud to generate the PDF, but I’m struggling with the config. All my services use Nginx Proxy Manager (NPM) to be exposed and handle the certificates and Cloudflare to proxy my public IP. In NPM I expose the local server IP with the port and it handles the proxy, but this does not work. Hope you can guide me. Here are my docker-compose.yml and my nginx.conf.


services:
  server:
    image: nginx
    restart: always
    environment:
      - APP_URL=http://fac.example.com
    volumes:
      # Vhost configuration
#      - ./config/caddy/Caddyfile:/etc/caddy/Caddyfile
      - ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro
      - /srv/dev-disk-by-label-D1/data/appdata/invoiceninja/public:/var/www/app/public:rw,delegated
      - /srv/dev-disk-by-label-D1/data/appdata/invoiceninja/storage:/var/www/app/storage:rw,delegated
    depends_on:
      - app
    ports:
      - "8888:80"
    networks:
      - invoiceninja

  app:
    image: invoiceninja/invoiceninja:5
    restart: always
    cap_add:
      - SYS_ADMIN
    environment:
      - APP_URL=http://fac.example.com
      - APP_KEY=base64:dp/cye89BtvaLyC+l6yFOE6lZ1YgwQTAMGVDniOtz6c=
      - MULTI_DB_ENABLED=false
      - DB_HOST1=db
      - DB_USERNAME1=ninja
      - DB_PASSWORD1=pass
      - DB_DATABASE1=ninja
      - PHANTOMJS_PDF_GENERATION=true
      - PHANTOMJS_SECRET='your-secret-here'
    volumes:
      - /srv/dev-disk-by-label-D1/data/appdata/invoiceninja/public:/var/www/app/public:rw,delegated
      - /srv/dev-disk-by-label-D1/data/appdata/invoiceninja/storage:/var/www/app/storage:rw,delegated
    depends_on:
      - db
    networks:
      - invoiceninja

  db:
    image: mysql:5
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=pass
      - MYSQL_USER=ninja
      - MYSQL_PASSWORD=pass
      - MYSQL_DATABASE=ninja
    volumes:
      - /srv/dev-disk-by-label-D1/data/appdata/invoiceninja/mysql-data:/var/lib/mysql:rw
    networks:
      - invoiceninja

volumes:
  mysql-data:
  public:
  storage:

networks:
  invoiceninja:
server {
    listen 80 default_server;
    server_name _ in.localhost;

    root /var/www/app/public/;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }
}

I’m sure my Nginx.conf is wrong and the issue should be related with it. My main questions are.

  • In the APP_URL in the docker-compose.yml should I use the final wed address with http or https?
  • The server_namein the Nginx.conf should point also to the web address or to the local IP of the server?
  • Am I missing something else?

Thank you for your time.

Hi There,

Your APP_URL should contain the Final Url you access the installation from, including the port number! this may be the missing link!

Thanks @david but that didn’t change anything. Could someone share their working docker-compose.yml + nginx.conf please?

Make sure you restart containers again after changing the docker-compose.yml file.

docker-compose down
docker-compose up -d

However, I’d rather tinker & finding the solution to generate PDFs locally rather than wasting time with Nginx, because I’m pretty sure our shipped nginx.conf is production-ready.

Thanks.

Finally got it working and thought I’ll share my config in case is useful to someone. I haven’t cloned the repo, just created the two file below and run the stack.

docker-compose.yml

version: '3'
services:

  db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=pass
      - MYSQL_PASSWORD=pass
      - MYSQL_DATABASE=ninja
      - MYSQL_USER=ninja
    volumes:
      -  /srv/dev-disk-by-label-D1/data/appdata/invoiceninja/db:/var/lib/mysql:rw
    networks:
      - invoiceninja

  app:
    image: invoiceninja/invoiceninja
    restart: always
    cap_add:
      - SYS_ADMIN
    environment:
      - APP_URL=http://192.168.1.115
      - APP_KEY=key
      - MULTI_DB_ENABLED=false
      - DB_HOST1=db
      - DB_USERNAME1=ninja
      - DB_PASSWORD1=pass
      - DB_DATABASE1=ninja
      #- PHANTOMJS_PDF_GENERATION=true
      #- PHANTOMJS_CLOUD_KEY='key'
      - EXPERIMENTAL_PDF_ENGINE=true
      - EXPERIMENTAL_PDF_ENGINE_CHROMIUM_PATH=/usr/bin/google-chrome
    volumes:
      -  ./public:/var/www/app/public:rw,delegated
      -  ./storage:/var/www/app/storage:rw,delegated
    depends_on:
      - db
    networks:
      - invoiceninja

  web:
    image: nginx
    restart: unless-stopped
    volumes:
      -  ./public:/var/www/app/public:rw,delegated
      -  ./storage:/var/www/app/storage:rw,delegated
      - ./nginx.conf:/etc/nginx/conf.d/in-vhost.conf:ro
    ports:
      - 8111:80
    networks:
      - invoiceninja

networks:
  invoiceninja:

nginx.conf

server {
    listen 80 default_server;
    server_name _ 192.168.1.115;

    #Remove X-Powered-By, which is an information leak
    fastcgi_hide_header X-Powered-By;


    root /var/www/app/public/;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /index.php$request_uri;
        add_header Cache-Control "public, max-age=15778463";
        # Optional: Don't log access to assets
        access_log off;
    }


    location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {
        try_files $uri /index.php$request_uri;
        # Optional: Don't log access to other assets
        access_log off;
    }

}

After running the containers, proxy your local IP and port through Nginx Proxy Manager, and you are done.

Thanks for sharing the working solution!

Are there any differences to our official docker file you think we should incorporate?