Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

[BUG] Exception\SuspiciousOperationException: Untrusted Host #65

Closed
urinal-cake opened this issue Jan 14, 2020 · 5 comments
Closed

[BUG] Exception\SuspiciousOperationException: Untrusted Host #65

urinal-cake opened this issue Jan 14, 2020 · 5 comments

Comments

@urinal-cake
Copy link

Again, this may be an issue with my lack of reading documentation properly, or not having the correct setup. Are there pre-requisites that I'm not aware of? Does the docker-compose properly take care of downloading and handling nginx?

Describe the bug
After starting the docker containers with the command 'docker-compose up -d' and navigating to the IP of the host that has kimai installed, the application in any browser displays a message that the host is untrusted. This appears to be a Symfony issue that, after researching, may be related to the docker-compose file not being correctly configured?

To Reproduce
Steps to reproduce the behaviour:

  1. sudo git clone https://github.com/tobybatch/kimai2.git kimai
  2. sudo cd /opt/kimai
  3. Comment out lines in the docker-compose related to start_period (18, 36, 54) to get around [BUG] Additional properties are not allowed ('start period' was unexpected) when using docker-compose #64
  4. docker-compose up -d
  5. Notice the following error is displayed:

Fatal error: Uncaught Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException: Untrusted Host "10.20.10.132". in /opt/kimai/vendor/symfony/http-foundation/Request.php:1191 Stack trace: #0 /opt/kimai/vendor/symfony/http-kernel/EventListener/ValidateRequestListener.php(41): Symfony\Component\HttpFoundation\Request->getHost() #1 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(298): Symfony\Component\HttpKernel\EventListener\ValidateRequestListener->onKernelRequest(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\EventDispatcher)) #2 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(260): Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher{closure}(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\EventDispatcher)) #3 /opt/kimai/vendor/symfony/event-dispatcher/EventDispatcher.php(235): Symfony\Component\EventDispatcher in /opt/kimai/vendor/friendsofsymfony/rest-bundle/View/ViewHandler.php on line 366

Desktop (please complete the following information):

  • OS: Ubuntu 18.04 bionic
  • Docker version: 19.03.5
  • Docker compose version: 1.17.1

Command used to run the container

  • docker-compose up -d

Docker compose file (with passwords redacted)

services:

  sqldb:
    image: mysql:5.7
    environment:
      - MYSQL_DATABASE=kimai
      - MYSQL_USER=kimaiuser
      - MYSQL_PASSWORD=kimaipassword
      - MYSQL_ROOT_PASSWORD=changemeplease
    volumes:
      - /var/lib/mysql
    command: --default-storage-engine innodb
    restart: unless-stopped
    healthcheck:
      test: mysqladmin -pchangemeplease ping -h localhost
      interval: 20s
      start_period: 10s
      timeout: 10s
      retries: 3 

  nginx:
    build: compose
    ports:
      - 8001:80
    volumes:
      - ./nginx_site.conf:/etc/nginx/conf.d/default.conf
    restart: unless-stopped
    depends_on:
      - kimai
    volumes:
      - public:/opt/kimai/public
    healthcheck:
      test:  wget --spider http://nginx/health || exit 1 
      interval: 20s
      start_period: 10s
      timeout: 10s
      retries: 3 

  kimai:
    image: kimai/kimai2:fpm-alpine-1.5-prod
    environment:
      - APP_ENV=prod
      - TRUSTED_HOSTS=localhost
      - ADMINMAIL=admin@kimai.local
      - ADMINPASS=changemeplease
    volumes:
      - public:/opt/kimai/public
      - var:/opt/kimai/var
    restart: unless-stopped
    healthcheck:
      test: wget --spider http://nginx || exit 1
      interval: 20s
      start_period: 10s
      timeout: 10s
      retries: 3

  postfix:
    image: catatnight/postfix
    environment:
      maildomain: neontribe.co.uk
      smtp_user: kimai:kimai
    restart: unless-stopped
    restart: always

volumes:
    var:
    public:

Additional context
Fresh new virtual machine with nothing but docker and docker-compose installed. Also, excuse me if I'm missing some crucial steps. I'm new to a fair bit of this.

@urinal-cake
Copy link
Author

I had another developer that found that if you change
- TRUSTED_HOSTS=localhost,theIpOfYourHost
then it will work

@tobybatch
Copy link
Owner

@urinal-cake you are completely correct it's due to the trusted hosts setting. I'll create a bug to cover this and see if we can document it better.

@z3rone
Copy link

z3rone commented Jun 4, 2020

@tobybatch I guess my confusion was that I've included the port with the hostname, Maybe you could point out in the doc that the port should be omitted.

Thanks for the support!

@calarndt
Copy link

This issue's solution is not complete...
Quoting @urinal-cake
I had another developer that found that if you change

  • TRUSTED_HOSTS=localhost,theIpOfYourHost

Excellent solution if one were to know WHERE to change that.
It exists in only in two .json files on my system. Both files buried way deep down inside
/var/lib/docker which to me appears to be the wrong place to change it.

I tried prefacing my docker command with that variable. No dice still my host is untrusted...
No idea where to go from here...

@tobybatch
Copy link
Owner

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

No branches or pull requests

4 participants