cachethq / Docker

A Dockerized version of Cachet.
https://cachethq.io
BSD 3-Clause "New" or "Revised" License
416 stars 281 forks source link

Email related stuff cause http 500 #432

Closed mangoman16 closed 16 hours ago

mangoman16 commented 1 day ago

Hello, this might somehow be related to: https://github.com/CachetHQ/Cachet/issues/4260

I am running a docker instance with reverse proxy nginx on the host, version: 2.4

I notice when i save the settings via gui, it does not change the .env correctly / completely:

MAIL_DRIVER=smtp
MAIL_HOST=mymailserver.com
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ADDRESS=noreply@nydomain.com
MAIL_NAME=null
MAIL_ENCRYPTION=tls

I noticed that username and password are actually left empty and after reloading the page it loads the initial email config: image which are wrong host and email user (noreply@status.mydomain.com)

I also tried to manually change the .env file, but this still did not fix the next problem i am going to mention: while trying to save the email configuration and testing it, it throws a 500 error:

IP - - [22/Oct/2024:15:17:38 +0000] "POST /dashboard/settings/mail/test HTTP/1.1" 500 3190 "https://domain.de/dashboard/settings/mail" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0" I found nothing in the host nginx error log and docker log of the cachet, i noticed someone else mentioning laravel log, i hope this is somehow related:

` [stacktrace]

0 [internal function]: Swift_Transport_StreamBuffer->{closure}(2, 'stream_socket_c...', '/var/www/html/v...', 264, Array)

1 /var/www/html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php(264): stream_socket_client('tcp://localhost...', 99, 'Address not ava...', 30, 4, Resource id #10)

2 /var/www/html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php(58): Swift_Transport_StreamBuffer->establishSocketConnection()

3 /var/www/html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(143): Swift_Transport_StreamBuffer->initialize(Array)

4 /var/www/html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(65): Swift_Transport_AbstractSmtpTransport->start()

5 /var/www/html/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(483): Swift_Mailer->send(Object(Swift_Message), Array)

6 /var/www/html/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(259): Illuminate\Mail\Mailer->sendSwiftMessage(Object(Swift_Message))

7 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php(65): Illuminate\Mail\Mailer->send(Object(Illuminate\Support\HtmlString), Array, Object(Closure))

8 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(144): Illuminate\Notifications\Channels\MailChannel->send(Object(CachetHQ\Cachet\Models\User), Object(CachetHQ\Cachet\Notifications\System\SystemTestNotification))

9 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(103): Illuminate\Notifications\NotificationSender->sendToNotifiable(Object(CachetHQ\Cachet\Models\User), 'e78e6961-c94e-4...', Object(CachetHQ\Cachet\Notifications\System\SystemTestNotification), 'mail')

10 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(19): Illuminate\Notifications\NotificationSender->Illuminate\Notifications\{closure}()

11 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(105): Illuminate\Notifications\NotificationSender->withLocale(NULL, Object(Closure))

12 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(77): Illuminate\Notifications\NotificationSender->sendNow(Object(Illuminate\Database\Eloquent\Collection), Object(CachetHQ\Cachet\Notifications\System\SystemTestNotification))

13 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(39): Illuminate\Notifications\NotificationSender->send(Object(Illuminate\Database\Eloquent\Collection), Object(CachetHQ\Cachet\Notifications\System\SystemTestNotification))

14 /var/www/html/vendor/laravel/framework/src/Illuminate/Notifications/RoutesNotifications.php(18): Illuminate\Notifications\ChannelManager->send(Object(CachetHQ\Cachet\Models\User), Object(CachetHQ\Cachet\Notifications\System\SystemTestNotification))

15 /var/www/html/app/Http/Controllers/Dashboard/SettingsController.php(307): CachetHQ\Cachet\Models\User->notify(Object(CachetHQ\Cachet\Notifications\System\SystemTestNotification))

16 [internal function]: CachetHQ\Cachet\Http\Controllers\Dashboard\SettingsController->testMail()

17 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)

18 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('testMail', Array)

19 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(CachetHQ\Cachet\Http\Controllers\Dashboard\SettingsController), 'testMail')

20 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\Routing\Route->runController()

21 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\Routing\Route->run()

22 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

23 /var/www/html/app/Http/Middleware/Authenticate.php(61): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

24 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): CachetHQ\Cachet\Http\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure))

25 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

26 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

27 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))

28 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

29 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(75): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

30 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))

31 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

32 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

33 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))

34 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

35 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

36 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))

37 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

38 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

39 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))

40 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

41 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

42 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))

43 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

44 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

45 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(684): Illuminate\Pipeline\Pipeline->then(Object(Closure))

46 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(659): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))

47 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))

48 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(614): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))

49 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))

50 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))

51 /var/www/html/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(58): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

52 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))

53 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

54 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

55 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))

56 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

57 /var/www/html/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

58 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))

59 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

60 /var/www/html/vendor/barryvdh/laravel-cors/src/HandlePreflight.php(29): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

61 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Barryvdh\Cors\HandlePreflight->handle(Object(Illuminate\Http\Request), Object(Closure))

62 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

63 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

64 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))

65 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))

66 /var/www/html/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))

67 {main}

"} ` Same behaviour when: trying to subscribe from frontend:

IP - - [22/Oct/2024:15:21:05 +0000] "POST /subscribe HTTP/1.1" 500 3185 "https://mydomain.de/subscribe" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0"

And adding a subscriber via backend: IP - - [22/Oct/2024:15:22:23 +0000] "POST /dashboard/subscribers/create HTTP/1.1" 500 3190 "https://mydomain.de/dashboard/subscribers/create" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0"

perhaps i am making a mistake on the reverse proxy side?

`server { listen 80; server_name mydomain.de; return 301 https://$host$request_uri; }

server { listen 443 ssl; server_name mydomain.de;

ssl_certificate /etc/letsencrypt/live/mydomain.de;/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.de;/privkey.pem;

location / {
    if ($remote_addr != "mypersonalip") {
        return 301 https://anotherdomain.de/serverstatus.php;
    }

    proxy_pass http://localhost:8000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

}`

Thanks for reading.

mangoman16 commented 1 day ago

my docker compose:

version: "3"

services:
  postgres:
    container_name: cpostgres
    image: postgres:12-alpine
    volumes:
      - ./sql:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=strongpassword
    restart: always
  cachet:
    container_name: ccachet
    build:
      context: .
      args:
        - cachet_ver=2.4
    ports:
      - 8000:8000
    links:
      - postgres:postgres
    environment:
      - DB_DRIVER=pgsql
      - DB_HOST=postgres
      - DB_PORT=5432
      - DB_DATABASE=postgres
      - DB_USERNAME=postgres
      - DB_PASSWORD=verystrong password 
      - DB_PREFIX=chq_
      - APP_KEY=base64:xxx=
      - APP_LOG=errorlog
      - APP_ENV=${APP_ENV:-production}
      - APP_DEBUG=false
      - DEBUG=false
    depends_on:
      - postgres
    restart: on-failure
    volumes:
      - ./www/imprint:/var/www/html/public/imprint:rw
      - ./www/fonts:/var/www/html/public/fonts:rw
      - ./www/img:/var/www/html/public/img:rw

also changed these in the nginx-site.conf: index index.php; --> to index index.html index.php;

and added: }

location = /imprint {
    rewrite ^ /imprint/index.html last;
}

but i do not understand how these could affect mail.

mangoman16 commented 16 hours ago

Hello,

setting the variables via the docker compose fixed this issue, sorry for the inconvenience