-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Warn for ws://
and wss://
site and upstream addresses
#5755
Comments
Hey @francislavoie I would like to take this up. Can you please assign this to me? |
You can just open up a PR when you have something 👍 |
I went through the code and was able to understand that an adapter is being used to adapt the config provided and convert it to json. I found there are multiple layers of abstractions which is making it slightly challenging to understand the flow of adaption. Would you like to point out some specific things that I should look for? |
@singhalkarun Maybe somewhere around here?
I wonder if we should just return an error if it's not http or https. Are there reasons to allow other schemes here? |
I think we should throw an error. If we try to use wss as proxy url prefix in nginx, it also throws error (saying invalid url prefix). Also, I believe we should only allow 3 vaues as scheme, http, https and empty scheme. Raising a PR as per this. |
We also support I think what we want is to specifically check for ws and wss and suggest http and https respectively if they use those. The solution for what they're trying to do is obvious, so the error message should tell them exactly what to do. This is also about the site addresses which is parsed elsewhere in the Caddyfile adapter. I'm on mobile right now so I can't get a link but I'm sure you can find where that's parsed. |
Oh yeah, I forgot about h2c (another preset).
That sounds good to me. |
Got it. As per my understanding, the following changes have to be made,
Please let me know if my understanding is correct before I take this up further. |
@singhalkarun I believe that's correct. If the scheme is ws or wss, a helpful error message specific to that is preferred. For every other unrecognized scheme, a general error message saying that scheme isn't recognized. Yeah, site blocks in the Caddyfile should probably be checked similarly as well. (I don't know if the h2c shortcut works there, though, I'd have to check.) |
It does not. Currently only http and https for site addresses. |
I've seen that commonly, users try to use
ws://
orwss://
either as site addresses or proxy upstream addresses. Neither of these work in Caddy, they're specific to browsers for use with thenew WebSocket(url)
JS API.We should warn/error when those are used in the config, and suggest using
http://
orhttps://
(or omitting the scheme) respectively.The text was updated successfully, but these errors were encountered: