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

WIP: Add websocket browser_redirect_url config option #1671

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

philpennock
Copy link
Member

If an HTTP(S) request is received without the Upgrade: header, then if this new
option is set then we'll assume it's a browser and issue a redirect.

There's no flexibility based upon the passed in URL; this should help with
redirecting people to dashboards or other tooling.

There's no documentation and no tests, this should not be merged as-is, the PR
exists for people to discuss, or replace with something better.

/cc @nats-io/core

If an HTTP(S) request is received without the Upgrade: header, then if this new
option is set then we'll assume it's a browser and issue a redirect.

There's no flexibility based upon the passed in URL; this should help with
redirecting people to dashboards or other tooling.
@philpennock
Copy link
Member Author

I left in that there's logging of an error for such a request, but the logging doesn't appear to pull in the source address. So two refinements suggest themselves:

  1. Make sure that we auto-decorate the returned error from the websocket upgrade to client IP information, for more useful logs
  2. Return a sentinel error and just don't bother logging these redirects at all

Either or both of these seem worthwhile. Thoughts?

Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I like this, but we also need to support operator driven versions where the redirect URL is contained in the operator JWT. /cc @matthiashanel

@matthiashanel
Copy link
Contributor

@derekcollison will add a corresponding jwt field to v2

@derekcollison
Copy link
Member

We should make sure we can eventually handle this properly with multi-operator setups.

@matthiashanel
Copy link
Contributor

We should make sure we can eventually handle this properly with multi-operator setups.

@derekcollison the way I would go about handling this in a multi operator setup is by calling out one of the operators to be operating the server.
This server would then pick the redirect from that particular operator only.
The other operators would be trusted but not operating this server.
This could be as simple as documenting that the first operator in the list is operating this server or have extra config to specify which one.

@derekcollison
Copy link
Member

I like that approach..

@kozlovic
Copy link
Member

@derekcollison @matthiashanel I am a bit confused. This parameter that @philpennock added is for situations where something connects to the Websocket port that is detected as likely not being a client (since it does not have the proper http headers). So obviously the option cannot be linked to a specific account (since there is no auth at the point the error is detected).
I assume then that you are referring to the JWT of the operator. But then the question is: why would this new configuration be different than any other? One would expect that if we decide that first operator in the list is the one operating the server, the config itself would be specific to this operator anyway.
I am not saying that it is bad that configuration be specific to an operator, but I wonder why this new option specifically.

@derekcollison
Copy link
Member

Yes operator JWT, and I think anything we can do to skinny down the actual server config in operator mode is a good thing. Much rather update operator JWT then all configs for all servers etc.

@aricart
Copy link
Member

aricart commented Oct 26, 2020

Since this is a websocket port, I am not sure why we do an HTTP redirect - websocket URLs for one are ws(s) - if an HTTP client hits the ws URL using a browser, redirecting doesn't seem like the right strat.

@aricart
Copy link
Member

aricart commented Oct 26, 2020

TBH, if we are going to do this here, then why aren't we doing a similar assertion on if a browser is pointed to the nats service port or if a nats client is pointed to the monitoring port.

@bruth
Copy link
Member

bruth commented Apr 23, 2023

@philpennock Is this still relevant?

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

Successfully merging this pull request may close these issues.

6 participants