You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/04/26 08:41:38 UTC

[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #1824: feat: support HTTPS for Manager API

nic-chen commented on a change in pull request #1824:
URL: https://github.com/apache/apisix-dashboard/pull/1824#discussion_r620089690



##########
File path: api/cmd/managerapi.go
##########
@@ -124,6 +124,24 @@ func NewManagerAPICommand() *cobra.Command {
 				}
 			}()
 
+			// HTTPS
+			if conf.SSLCert != "" && conf.SSLKey != "" {
+				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,
+				}
+				go func() {
+					err := serverSSL.ListenAndServeTLS(conf.SSLCert, conf.SSLKey)
+					if err != nil && err != http.ErrServerClosed {
+						utils.CloseAll()
+						log.Fatalf("listen and serv fail: %s", err)
+					}
+				}()
+			}
+
 			printInfo()

Review comment:
       updated.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org