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

Support https for both client and server #875

Merged
merged 9 commits into from
Dec 21, 2022

Conversation

samanhappy
Copy link
Collaborator

Resolve #60

@codecov-commenter
Copy link

codecov-commenter commented Dec 14, 2022

Codecov Report

Base: 76.03% // Head: 76.15% // Increases project coverage by +0.12% 🎉

Coverage data is based on head (7fe89df) compared to base (be4d396).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #875      +/-   ##
==========================================
+ Coverage   76.03%   76.15%   +0.12%     
==========================================
  Files         110      110              
  Lines       12741    12741              
==========================================
+ Hits         9687     9703      +16     
+ Misses       2507     2496      -11     
+ Partials      547      542       -5     
Impacted Files Coverage Δ
pkg/object/autocertmanager/autocertmanager.go 93.46% <0.00%> (-0.82%) ⬇️
pkg/filters/proxy/pool.go 80.17% <0.00%> (+0.87%) ⬆️
pkg/object/mqttproxy/broker.go 75.80% <0.00%> (+1.00%) ⬆️
pkg/cluster/op.go 66.46% <0.00%> (+1.82%) ⬆️
pkg/cluster/syncer.go 82.05% <0.00%> (+4.48%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

pkg/option/option.go Outdated Show resolved Hide resolved
pkg/api/server.go Outdated Show resolved Hide resolved
pkg/api/server.go Outdated Show resolved Hide resolved
@localvar
Copy link
Collaborator

hi @samanhappy , I was thinking of improving the user experience of egctl, I think we can make it auto-detect if HTTPS is enabled in the server or not.

to achieve this, we need the following:

  • if tls is false, use http
  • if tls is true, use https
  • if tls is not configured, then default to auto, which means try http then https (or vice versa)

the only issue is, under auto mode, how much time egctl will spend to know that the server does not support HTTP or https.

@samanhappy
Copy link
Collaborator Author

@localvarauto is always good for user, I found specific error messages for nonconsistent http/https requests:

  • use http visit https will get a 400 status and body "Client sent an HTTP request to an HTTPS server.\n"
  • use https visit http will get a error with message "http: server gave HTTP response to HTTPS client"

maybe we can do a retry work for these error message, how about it?

@localvar
Copy link
Collaborator

@samanhappy how much time does it cost? I think this is fine if it is under a few hundred milliseconds.
but please rely on the status code instead of the error message, because, it is possible that there's an nginx between easegress and egctl.

I propose to try HTTP first, and if we got 400, then try HTTPS.

@samanhappy
Copy link
Collaborator Author

@localvar it should be quick because there's only a network overhead without business logic, how about this flow:

  • tls is false by default, so use HTTP first, if got a 400 and body Client sent an HTTP request to an HTTPS server.\n, then use HTTPS
  • tls is true, use HTTPS

@localvar
Copy link
Collaborator

this is fine, but please change the option name tls to something like force-tls.

@suchen-sci suchen-sci merged commit f99cd41 into easegress-io:main Dec 21, 2022
@samanhappy samanhappy deleted the https branch January 13, 2023 09:53
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.

[issue] Cli supports http only
4 participants