bestlibre / hassio-addons

173 stars 110 forks source link

Caddy Proxy: multi line Raw config #70

Closed einschmidt closed 6 years ago

einschmidt commented 6 years ago

The Caddy proxy currently supports single line raw configurations only: "raw_config": [ { "line": "proxy XYZ.duckdns.org 172.17.0.1:8123" }

However, the power of Caddy can be revieled with multi lines only. Therefore it should be possible to achieve the following Caddy configuration:

proxy XYZ.duckdns.org 172.17.0.1:8123 {
   keepalive 10
   max_fails 0
}

I am not sure where and how, but maybe it would be sufficient enough to allow multiple "line" entries? Example:

"raw_config": [
    {
      "line": "proxy XYZ.duckdns.org 172.17.0.1:8123 {"
      "line": "    keepalive 10"
      "line": "}"
    }
einschmidt commented 6 years ago

Just found out it was a mistake in my config. It is already possible...

regystro commented 5 years ago

Just found out it was a mistake in my config. It is already possible...

Could you please share how did you manage to do that? I see you are missing the commas in your example, but once corrected I'm unable to use several "line":"content", because when I save the config and reload the add-on page, it only shows the last one.

So:

"raw_config": [
    {
      "line": "proxy XYZ.duckdns.org 172.17.0.1:8123 {",
      "line": "    keepalive 10",
      "line": "}"
    }]

becomes:

  "raw_config": [
    {
      "line": "}"
    }]

I've only been able to use multiple lines this way:

"raw_config": [
    {
      "line": "proxy XYZ.duckdns.org 172.17.0.1:8123 {\n     keepalive 10\n }"
    }]

...but I consider it a workaround.

einschmidt commented 5 years ago

At the end I solved it this way:

"raw_config": [
    {
      "line": "proxy XYZ.duckdns.org 172.17.0.1:8123 {"
    },
    {
      "line": "  keepalive 10"
    },
    {
      "line": "}"
    }
]
regystro commented 5 years ago

Great, thanks for sharing!!

At the end I solved it this way:

"raw_config": [
    {
      "line": "proxy XYZ.duckdns.org 172.17.0.1:8123 {"
    },
    {
      "line": "  keepalive 10"
    },
    {
      "line": "}"
    }
]

Great, thanks for sharing!!

bestlibre commented 5 years ago

I don't use this anymore... I will look at it to see if I can improve the style. A list of strings should be enough !

bestlibre commented 5 years ago

The last release simplify the syntax with a list of string only. Your example will become :

"raw_config": [
    "proxy XYZ.duckdns.org 172.17.0.1:8123 {",
    "  keepalive 10",
    "}"
]