pentacent / keila

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

Problem with public facing links #323

Closed bpivk closed 3 months ago

bpivk commented 3 months ago

I have deployed keila on a server which hosts it under: mailing.something.com

The ports on the docker are 4000 as default.

My problem is that even the text Powered by [Keila - OpenSource Newsletters] adds the port to my server. That means that all the links become mailing.something.com:4000.

How do I omit the port?

bpivk commented 3 months ago

Fixed. In my case it was down to two parameters that I had to edit.

wmnnd commented 3 months ago

Glad you found a solution! For anyone else looking for a solution to this: You can configure URL_PORT and URL_SCHEME for your Keila instance. See https://www.keila.io/docs/configuration

bpivk commented 3 months ago

That was part of my problem. My docker was set to 4000:4000 as per default and that was messing my installation up. PORT was the variable needed and it had to be set from 4000 as default to 443. Then I had to set the docker container to forward 443 as 4000 (443 is taken) and it started working. If the port is set to 4000 then even if my proxy was handling the app it still appended the port. Thus making something.com to something.com:4000

I hope it's clear for anyone else that has issues.

wmnnd commented 3 months ago

No need to use 443 as the internal port! Just set URL_SCHEMA to https. This will also correctly URL_PORT (which can be independent from PORT and which you could simply leave at 4000).

URL_PORT is for the outward-facing links generated by Keila, PORT is only the internally used port in the Docker container.

bpivk commented 3 months ago

Then this happens: image

This is with URL_SCHEMA and URL_HOST set. These are the only two settings and it breaks the link.

bpivk commented 3 months ago

So this is the output when I check logs: Access KeilaWeb.Endpoint at http://xxx.xxxx.net:4000

And when I add PORT it works even when I remove URL_SCHEMA: Access KeilaWeb.Endpoint at https://xxx.xxxx.net

wmnnd commented 3 months ago

What if you just set URL_PORT?

wmnnd commented 3 months ago

This is the logic that Keila uses to set port and schema:

url_host = System.get_env("URL_HOST")
url_port = System.get_env("URL_PORT") |> maybe_to_int.()
url_schema = System.get_env("URL_SCHEMA")
url_path = System.get_env("URL_PATH")

url_port =
  cond do
    url_port not in [nil, ""] -> url_port
    url_schema == "https" -> 443
    true -> System.get_env("PORT") |> maybe_to_int.() || 4000
  end

url_schema =
  cond do
    url_schema not in [nil, ""] -> url_schema
    url_port == 443 -> "https"
    true -> "http"
  end

So setting URL_SCHEMA=https (case sensitive!) is really all you need.