snoyberg / keter

Web app deployment manager
MIT License
260 stars 71 forks source link

Document config file options #129

Open 3noch opened 8 years ago

3noch commented 8 years ago

The example configs are enough to get someone up and running with a basic setup, but any of the advanced features are utterly inaccessible!

tolysz commented 8 years ago

Could you say what you are trying to do? Maybe it will be easier to post code snippets.

3noch commented 8 years ago

I've heard others make this general complaint before as well. I'm not sure what they were trying to do. The "straw" that caused me to create this issue was looking at the example of various middlewares and their configuration options. It's non-obvious what middlewares are available nor how to configure them. I'd love a static GZIP middleware myself.

tolysz commented 8 years ago

I only used it once :) We need a proper WAI static supporting pre-GZIP files which will be decompressed if the client does not support it.

Otherwise; one would need to send 'gziped' files with normal extensions and inject header that it is gzipped i.e. encoding deflate or something

  middleware:
     - headers:
        Access-Control-Allow-Origin : "*"
        Content-Encoding : gzip
creichert commented 8 years ago

@3noch All the advanced configuration options should be specified in this example: https://github.com/snoyberg/keter/blob/master/incoming/foo1_0/config/keter.yaml#L39

They aren't necessarily well-documented, but they should all be there. Since they are essentially the middlewares found in wai-extra, you can check that package for more info (although, the keter middlewares support limited options).

If you wanted to add support for gzip, you could also look here: https://github.com/snoyberg/keter/blob/e8b5a3fd5e14dfca466f8acff2a02f0415fceeb0/Keter/Types/Middleware.hs#L32

3noch commented 8 years ago

@creichert This is a great start! I'll consider adding GZip support somehow.

Regarding the issue itself, is there a plan in place for how/where to put documentation for this? I see that stack has started using a nice system for hosting docs. If keter is a tool that people should seriously consider using, it seems worthy to have some real docs.

vlatkoB commented 8 years ago

I want to send traffic from foo.bar to localhost/abc. This is (shorten) keter.yml:

  - type: webapp
    hosts:
      - localhost

  - type: reverse-proxy
    reversed-host:   localhost
    reversed-port:   80
    reversing-host:  foo.bar
    rewrite-request:
       - header: Location
         from:   ^(.*)
         to:     /abc/$1

This sends traffic from http://foo.bar to http://localhost, but not to http://localhost/abc. Example keter.yaml doesn't mention any rewrite rules. (Also, seems reversed-host: and reversing-host: are mixed in example keter.yml)

tolysz commented 8 years ago

Just checking: https://hackage.haskell.org/package/keter-1.3.7/docs/src/Network-HTTP-ReverseProxy-Rewrite.html#rewrite

rewrite-request:
   - header: Location
     from:   "^(.*)"
     to:     "/abc/\1"
  # or maybe \\1 

Or something like that (as I do not see $$$ there)

vlatkoB commented 8 years ago

Thanks for pointing that out. I took the Rewrite module and tested it with

let rr   = RewriteRule "" "^http://foo.bar/(.*)"  "http://localhost/abc/\\1"
    url  = "http://foo.bar/test/x?qq=ww"
    res  = regexRewrite rr url
print res

The output is as expected

http://localhost/abc/test/x?qq=ww

but, rewriting still doesn't work. Must be something else.

creichert commented 8 years ago

@vlatkoB There isn't a configuration example for rewriting yet due to the tricky config. If you figure it out, it would be really nice to add the example to the example config: https://github.com/snoyberg/keter/blob/master/incoming/foo1_0/config/keter.yaml

vlatkoB commented 8 years ago

I debugged it a little and seems that rewrite-request: header: rewrites only the specified header (in my case Location) which is not present in my case.

Not sure that functionality is similar to, say, Apache's RewriteRule. Maybe @snoyberg can say a word or two?

snoyberg commented 8 years ago

I had very little input on the rewriting logic, I don't really know what the intention was.