monicahq / monica

Personal CRM. Remember everything about your friends, family and business relationships.
https://beta.monicahq.com
GNU Affero General Public License v3.0
21.81k stars 2.19k forks source link

Omitting port on docker stops Monica from functioning #6930

Closed cellulosa closed 1 year ago

cellulosa commented 1 year ago

Bug description

Hi there, I just got up and running the latest version of Monica (Chandler) on Docker.

I notice that if I omit the port declaration, so as to connect to monica via a caddy proxy, there are all sorts of errors being thrown e.g. corss or 419 or Blocked loading mixed active content errors.

How to reproduce

Add the following on docker-compose.yml and start with docker-compose up.

monica:
  container_name: monica
  image: ghcr.io/monicahq/monica-next:main
  environment:
    - MAIL_MAILER=log
  restart: unless-stopped

caddy:
  container_name: caddy
  image: caddy:latest
  volumes:
    - ~/caddy/Caddyfile:/etc/caddy/Caddyfile

Have configured Caddyfile to proxy with (this works for other services because caddy runs within docker):

my-domain.com {
    import cert
    reverse_proxy monica:80
}

Environment

cellulosa commented 1 year ago

I think it's something to do with resources being called via http despite the APP_URL is set to enforce https://my-domain.com and APP_ENV is set to production (see this)

Screenshot 2023-10-11 at 17 41 15

cellulosa commented 1 year ago

Maybe this helps? https://stackoverflow.com/questions/40910663/laravel-action-helper-ignores-app-url-environment-variable

cellulosa commented 1 year ago

after doing some digging on the repo, I managed to get it working by adding - APP_TRUSTED_PROXIES=*.

I will open a PR to provide some instructions for others!

zktaiga commented 1 year ago

after doing some digging on the repo, I managed to get it working by adding - APP_TRUSTED_PROXIES=*.

I will open a PR to provide some instructions for others!

Did you need anything else? I am in the same situation and running out of options.

APP_ENV=production
APP_URL=
APP_TRUSTED_PROXIES=*

No luck. Has anything changed from a Chandler perspective? Don't have the same issue with the old Monica deployment.

cc @djaiss have there been any changes in the underlying proxy at all?

cellulosa commented 1 year ago

here is my full config:

monica:
  container_name: monica
  image: ghcr.io/monicahq/monica-next:main
  volumes:
    - ${DOCKER_CONFIG_DIR}/monica/database.sqlite:/var/www/html/storage/database.sqlite
  environment:
    - APP_ENV=production
    - APP_URL=https://monica.my-website.com
    - APP_TRUSTED_PROXIES=*
    - APP_KEY=${MONICA_APP_KEY}
    - DB_DATABASE=/var/www/html/storage/database.sqlite
    - DB_PASSWORD=${MONICA_MYSQL_PASS}
    - MAIL_MAILER=log
    - LOCATION_IQ_API_KEY=${MONICA_LOCATION_IQ_API_KEY}
    - MAPBOX_API_KEY=${MONICA_MAPBOX_API_KEY}
    - MAPBOX_USERNAME=${MONICA_MAPBOX_USERNAME}
    - UPLOADCARE_PUBLIC_KEY=${MONICA_UPLOADCARE_PUBLIC_KEY}
    - UPLOADCARE_PRIVATE_KEY=${MONICA_UPLOADCARE_PRIVATE_KEY}
  ports:
    - 8080:80
  restart: unless-stopped

I then have Caddy running locally that proxies to Monica with:

(cert) {
    tls {
        dns cloudflare {$CLOUDFLARE_API_TOKEN}
    }
}

monica.my-website.com {
    import cert
    reverse_proxy :8080
}
github-actions[bot] commented 1 month ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.