-
Notifications
You must be signed in to change notification settings - Fork 528
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
feat: support HTTPS for Manager API #1824
Conversation
Deploy preview for apisix-dashboard ready! Built with commit 356ca4c |
Codecov Report
@@ Coverage Diff @@
## master #1824 +/- ##
==========================================
- Coverage 72.07% 71.59% -0.49%
==========================================
Files 125 172 +47
Lines 2944 6119 +3175
Branches 711 711
==========================================
+ Hits 2122 4381 +2259
- Misses 822 1490 +668
- Partials 0 248 +248
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
} | ||
}() | ||
} | ||
|
||
printInfo() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to update the printInfo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
api/cmd/managerapi.go
Outdated
addrSSL := fmt.Sprintf("%s:%d", conf.ServerHost, conf.SSLPort) | ||
serverSSL := &http.Server{ | ||
Addr: addrSSL, | ||
Handler: r, | ||
ReadTimeout: time.Duration(1000) * time.Millisecond, | ||
WriteTimeout: time.Duration(5000) * time.Millisecond, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, Nice work 👍 .
I think we should go
with adding a custom TLS configuration to make it more secure. Also, a go server automatically upgrades requests to HTTP/2 if a tlsconfig is set with HTTPS.
Referring to an awesome blog from cloudflare.
Thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated. thanks.
api/cmd/managerapi.go
Outdated
@@ -124,6 +128,29 @@ func NewManagerAPICommand() *cobra.Command { | |||
} | |||
}() | |||
|
|||
// HTTPS | |||
if conf.SSLCert != "" && conf.SSLKey != "" { | |||
addrSSL := fmt.Sprintf("%s:%d", conf.ServerHost, conf.SSLPort) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use net.JoinHostPort
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
api/cmd/managerapi.go
Outdated
err := serverSSL.ListenAndServeTLS(conf.SSLCert, conf.SSLKey) | ||
if err != nil && err != http.ErrServerClosed { | ||
utils.CloseAll() | ||
log.Fatalf("listen and serv fail: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Fatalf("listen and serv fail: %s", err) | |
log.Fatalf("listen and serve fail: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
|
||
# ssl: | ||
# host: 127.0.0.1 # the address on which the `Manager API` should listen for HTTPS. | ||
# The default value is 0.0.0.0, if want to specify, please enable it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may also support the mTLS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. we may support mTLS in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Please answer these questions before submitting a pull request, or your PR will get closed.
Why submit this pull request?
What changes will this PR take into?
Support for HTTPS by configuring SSL certificate.
Related issues
resolve #1706
Checklist: