Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does keter override yesod's approot? #145

Open
jwaldmann opened this issue May 29, 2016 · 10 comments
Open

does keter override yesod's approot? #145

jwaldmann opened this issue May 29, 2016 · 10 comments

Comments

@jwaldmann
Copy link

jwaldmann commented May 29, 2016

I cannot get the following to work:

  • from the outside, I want to provide https://foo.bar/app (because there are other services on that machine, and I have shibboleth access control on /app)
  • apache should proxy this to localhost:3000, where I have a keterized yesod app running

What do I put as approot in the application's config/settings.yml ? I thought it should be https://foo.bar/app/ (the externally visible name) but this does not work (the application does not produce the "/app" prefix).

When I start the app directly (without keter) the behaviour is as expected. So keter must have some effect on the application. Where is that documented?

@tolysz
Copy link
Contributor

tolysz commented May 29, 2016

I remember I had to do something inside the app itself, but I managed to make it work.
I am not sure if the keter supports it directly. I will have a look once I get home, maybe I will post some snippet.
(Or we can look how to implement it in keter)

@jwaldmann
Copy link
Author

In the standard keter.yml, this sounds suspicious:

    hosts:
      # You can specify one or more hostnames for your application to respond
      # to. The primary hostname will be used for generating your application
      # root.
  • it indicates that keter somehow mangles the application root
  • but I have no idea how exactly.

@tolysz
Copy link
Contributor

tolysz commented May 29, 2016

Let me understand it better:
Your keter or your app is running on localhost:3000? If keter, Are you going to have one or more apps?
My impression is: that currently, If it is only one app, you could do it with cleanpath, but without keter.

To do it with keter we would need to extend it... but if anyone knows better please correct me :)

@jwaldmann
Copy link
Author

keter is running on localhost:3000, because I have in /opt/keter/etc/keter-config.yaml:

listeners:
    # HTTP
    - host: "127.0.0.1" # Listen only to localhosts
      port: 3000

@jwaldmann
Copy link
Author

jwaldmann commented May 29, 2016

meanwhile, I found this https://github.com/snoyberg/keter/blob/master/Keter/App.hs#L297

            , Map.singleton "APPROOT" $ scheme <> CI.original waconfigApprootHost <> pack extport

and I conclude that keter sets APPROOT to http[s]://hostname[:port], ignoring any path. I consider this a bug. Well, a missing feature. Cannot be too hard to add? Design question is where to put the information.

@tolysz
Copy link
Contributor

tolysz commented May 29, 2016

I am not an expert here :), but to add dispatch on path, we would need to add additional proxy level, and have 2 level (host, path) dispatching.
Therefore, currently, it would work for only one app per domain.

@jwaldmann
Copy link
Author

jwaldmann commented May 29, 2016

would be fine, I have only one app. I do not want to dispatch on path (my apache is doing this?) I just want to pass the correct value of APPROOT to my application.

As a work-around, is there a way to set APPROOT in some other place? source code says

        env = Map.toList $ Map.unions
            [ waconfigEnvironment
            , forwardedEnv
            , Map.fromList otherEnv
            , kconfigEnvironment ascKeterConfig

so if I could put APPROOT in one of these, then it should be good? But how can I? I have no idea what these examples mean (in https://github.com/snoyberg/keter/blob/master/incoming/foo1_0/config/keter.yaml#L14 )

stanzas:
    - type: webapp
...
      env:
        FROM_KETER_CONFIG: foo bar baz
      forward-env:
        - FROM_SYSTEM_ENV
        - ANOTHER_ENV_VAR

Ah! I put this in my application's config/keter.yml:

stanzas:
  - type: webapp
    env:
      APPROOT: "https://foo.bar/app"

@tolysz
Copy link
Contributor

tolysz commented May 29, 2016

I doubt we can :), as it will generate more bugs.

But we can think how to allow dispatching on path, most likely it should be possible, if we just improve the routing. Most likely do lookup based on host and path. Then we need to know if we want to rewrite(remove) path or forward it to the app.

The problem I see is how to efficiently analyse path only for hosts which are configured with path.

@jwaldmann
Copy link
Author

Sorry, I was re-editing my comment while you were answering. I seem to have a work-around now. Thanks for your time. Feel free to keep this issue open, or close.

@sbditto85
Copy link

as a side note you can override the APPROOT in your Foundation.hs (https://github.com/yesodweb/yesod/wiki/Overriding-approot)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants