HTTPS configuration

Hi,

I have a problem with HTTPS. I’ve hosted invoice-ninja on docker.
When I set:

APP_URL=https://invoice.test.com
REQUIRE_HTTPS: true

and after running docker-compose and navigating to https://invoice.test.com I receive an error:

ERR_CONNECTION_REFUSED

After changing:

REQUIRE_HTTPS: false

I can navigate to http://invoice.test.com.

My docker-compose:

version: "3.9"
services:
  invoice-ninja-server:
    image: nginx
    container_name: invoice-ninja-server
    hostname: invoice-ninja-server
    ports:
      - 80:80
      - 443:443
    environment:
      - DB_HOST=127.0.0.1
      - DB_PORT=3306
      - DB_DATABASE=invoice
      - DB_USERNAME=invoice
      - DB_PASSWORD=invoice
    volumes:
      - /path/to/Caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com
      - /path/to/invhost/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf
      - /path/to/app/public:/var/www/app/public
    depends_on:
      - invoice-ninja-app
    restart: always
    labels:
      hostname: invoice-ninja-server
    logging:
      driver: "json-file"
      options:
        max-size: "10M"
        max-file: "7"
        labels: "hostname"

  invoice-ninja-app:
    image: invoiceninja/invoiceninja:5.5
    container_name: invoice-ninja-app
    hostname: invoice-ninja-app
    ports:
      - 9000:9000
    environment:
      - APP_URL=https://invoice.test.com
      - APP_KEY=<key>
      - APP_CIPHER='AES-256-CBC'
      - APP_DEBUG=true
      - APP_NAME=Invoice
      - REQUIRE_HTTPS=true
      - PHANTOMJS_PDF_GENERATION=false
      - PDF_GENERATOR=snappdf
      - TRUSTED_PROXIES='*'
      - QUEUE_CONNECTION=redis
      - DB_HOST=127.0.0.1
      - DB_PORT=3306
      - DB_DATABASE=invoice
      - DB_USERNAME=invoice
      - DB_PASSWORD=invoice
      - IN_USER_EMAIL=ninja
      - IN_PASSWORD=ninja
      - CACHE_DRIVER=redis
      - SESSION_DRIVER=redis
      - REDIS_HOST=127.0.0.1
      - REDIS_PORT=6379
      - IS_DOCKER=true
      - NINJA_ENVIRONMENT=selfhost
      - BROADCAST_DRIVER=pusher
    volumes:
      - /path/to/host/hosts:/etc/hosts
      - /path/to/app/public:/var/www/app/public
      - /path/to/app/storage:/var/www/app/storage
    restart: always
    labels:
      hostname: invoice-ninja-app
    logging:
      driver: "json-file"
      options:
        max-size: "10M"
        max-file: "7"
        labels: "hostname"

networks:
  default:
    name: invoice-network
    external: true

Do I do something wrong with the configuration or should I change something in in-vhost.conf file?

Best regards!

Hi,

@david do you have any suggestions?

You will need to configure the vhost file and configure the ssl certificate.

@david Thanks a lot! It works now.