pentacent / keila

Open Source Newsletter Tool.
https://keila.io
GNU Affero General Public License v3.0
1.44k stars 81 forks source link

Campaign textarea not working - websocket issue #324

Closed Marthaarman closed 3 months ago

Marthaarman commented 3 months ago

In either mode (plain, markdown or block), the input is not registered.

In plaintext mode, nothing is displayed in the preview In the other two modes I cannot provide input.

image The image shows the beta block editor but as you can see, empty and no suggestions.

My setup:

  1. git clone git@github.com:pentacent/keila.git .

  2. cp ops/docker-compose.yml .

  3. cp ops/Dockerfile .

  4. nano .env

.env:

YOUR_SECRET_KEY=xxxxx
YOUR_URL_HOST=mywebsite.com
YOUR_URL_PORT=443
YOUR_URL_PATH=/
YOUR_MAILER_SMTP_HOST=smtp.mywebsite.com
YOUR_MAILER_SMTP_USER=myname@mywebsite.com
YOUR_MAILER_SMTP_PASSWORD=mysmtppassword
YOUR_MAILER_SMTP_PORT=465
KEILA_USER=myname@mywebsite.com
KEILA_PASSWORD=myuserpassword
PORT=4000

docker-compose.yml

services:
  keila:
    image: pentacent/keila:latest
    ports:
      - "4000:4000"
    depends_on:
      - postgres
    build:
      context: .
    environment:
      SECRET_KEY_BASE: "${YOUR_SECRET_KEY}"
      DB_URL: "postgres://postgres:postgres@postgres/postgres"
      URL_HOST: "${YOUR_URL_HOST}"
      URL_PORT: "${YOUR_URL_PORT}"
      URL_PATH: "${YOUR_URL_PATH}"
      KEILA_USER: "${KEILA_USER}"
      KEILA_PASSWORD: "${KEILA_PASSWORD}"
      MAILER_SMTP_HOST: "${YOUR_MAILER_SMTP_HOST}"
      MAILER_SMTP_USER: "${YOUR_MAILER_SMTP_USER}"
      MAILER_SMTP_PASSWORD: "${YOUR_MAILER_SMTP_PASSWORD}"
      MAILER_SMTP_PORT: "${YOUR_MAILER_SMTP_PORT}"
      USER_CONTENT_DIR: "./data/uploads"
    networks:
      keila_nw:
      nginx_reverse_proxy:
        ipv4_address: 172.25.0.8
  postgres:
    image: postgres:alpine
    environment:
      POSTGRES_PASSWORD: postgres
    volumes:
      - ./data/postgres:/var/lib/postgresql/data
    networks:
      keila_nw:

networks:
  keila_nw:
  nginx_reverse_proxy:
    name: network_nginx_reverse_proxy
    external: true
  1. docker compose up --build -d

What could be wrong here? I see nothing in the logs (when I load the campaign page) with:

docker compose logs -f

keila-1     | 12:25:45.790 [info] Loading 147 CA(s) from :otp store
keila-1     | 12:25:45.791 [warning] Captcha not configured.
keila-1     | Keila will fall back to using hCaptcha’s staging configuration.
keila-1     | 
keila-1     | To configure a captcha, use the following environment variables:
keila-1     | 
keila-1     | - CAPTCHA_SITE_KEY
keila-1     | - CAPTCHA_SECRET_KEY
keila-1     | - CAPTCHA_URL (defaults to https://hcaptcha.com/siteverify or https://api.friendlycaptcha.com/api/v1/siteverify)
keila-1     | - CAPTCHA_PROVIDER (defaults to hCaptcha, unless set to 'friendly_captcha')
keila-1     | 
keila-1     | 12:25:45.791 [warning] You have not configured a Hashid salt. Defaulting to
keila-1     | :crypto.hash(:sha256, SECRET_KEY_BASE <> "hashid_salt") |> Base.url_encode64()
keila-1     | 
keila-1     | 12:25:45.792 [warning] You have not configured a separate URL for untrusted content uploaded by
keila-1     | users.
keila-1     | 
keila-1     | If you serve user uploads on a different domain, you can set
keila-1     | USER_CONTENT_BASE_URL
keila-1     | 
keila-1     | 12:25:45.936 [info] Migrations already up
keila-1     | 12:25:45.948 [info] Database already populated, not populating database.
keila-1     | 12:25:45.952 [info] Running KeilaWeb.Endpoint with cowboy 2.10.0 at 0.0.0.0:4000 (http)
keila-1     | 12:25:45.953 [info] Access KeilaWeb.Endpoint at https://mywebsite.com
keila-1     | 12:25:49.485 [info] tzdata release in place is from a file last modified Fri, 22 Oct 2021 02:20:47 GMT. Release file on server was last modified Thu, 01 Feb 2024 18:40:48 GMT.
keila-1     | 12:25:50.922 [info] Tzdata has updated the release from 2021e to 2024a
keila-1     | 12:26:03.460 [info] CONNECTED TO Phoenix.LiveView.Socket in 22µs
keila-1     |   Transport: :websocket
keila-1     |   Serializer: Phoenix.Socket.V2.JSONSerializer
keila-1     |   Parameters: %{"_csrf_token" => "cQ4BETUvKWNsBAwADD8fBwYhKlwbHSgH6ABaPEA3_HHsMhilNND4oubS", "_mounts" => "0", "_track_static" => %{"0" => "https://mywebsite.com/css/app-f48b72e50173858b8413455576d73aa0.css?vsn=d", "1" => "https://mywebsite.com/js/app-b7e12a3aa2e305b2a621b2970bfc8352.js?vsn=d"}, "vsn" => "2.0.0"}
keila-1     | 12:26:30.987 request_id=F-pdqbrSRNkgal0AABIh [info] GET /projects/np_weLJnLY5/campaigns/nmc_2yLDNVbQ
keila-1     | 12:26:31.070 request_id=F-pdqbrSRNkgal0AABIh [info] Sent 200 in 82ms

Message in firefox console:

Firefox can’t establish a connection to the server at wss://mywebsite.com/live/websocket?_csrf_token=MhYqHkgFDT9XKnASNQIcMiYNWAMsHx0ZuYin-oeodf4atUjYnb6kXwWM&_track_static%5B0%5D=https%3A%2F%2Fmywebsite.com%2Fcss%2Fapp-f48b72e50173858b8413455576d73aa0.css%3Fvsn%3Dd&_track_static%5B1%5D=https%3A%2F%2Fmywebsite.com%2Fjs%2Fapp-b7e12a3aa2e305b2a621b2970bfc8352.js%3Fvsn%3Dd&_mounts=0&vsn=2.0.0. 3 app-b7e12a3aa2e305b2a621b2970bfc8352.js:229:58271

My reverse proxy:

server {
    listen 80;
    listen [::]:80;
    server_name mysite.com;

    location ~ /.well-known/acme-challenge {
        allow all;
        root /tmp/acme_challenge;
    }

    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443;
    listen [::]:443 ssl http2;
    server_name mysite.com;

    # all ssl related config moved to ssl.conf
    ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem;

    server_tokens off;

    location / {
        proxy_pass         http://keila:4000/;
        proxy_set_header   Host $http_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-Host $server_name;
        proxy_set_header   X-Forwarded-Proto https;
    proxy_set_header   Upgrade $http_upgrade;
    proxy_set_header   Connection "upgrade";
        proxy_read_timeout  1200s;

        client_max_body_size 0;
    }

    location ~ /\. {
        deny all;
    }
}
Marthaarman commented 3 months ago

solution

I needed to add the line

proxy_http_version 1.1;

into my reverse proxy

wmnnd commented 3 months ago

Glad you figured it out!