diff options
author | 2021-11-22 10:55:52 +0100 | |
---|---|---|
committer | 2021-11-22 10:55:52 +0100 | |
commit | 1ded58b34b72c8e6862c5614882fd5a3bb430aaa (patch) | |
tree | a57350333cf51100fca3ecb21152626a03e0bed3 /internal/router/router.go | |
parent | properly initialize user client module (#319) (diff) | |
download | gotosocial-1ded58b34b72c8e6862c5614882fd5a3bb430aaa.tar.xz |
add bindAddress configuration option (#320)
* add bindAddress configuration option
* clarify that bindAddress can be a hostname
Diffstat (limited to 'internal/router/router.go')
-rw-r--r-- | internal/router/router.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/internal/router/router.go b/internal/router/router.go index 130832f74..aef5c32e4 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -72,7 +72,8 @@ func (r *router) Start() { if r.config.LetsEncryptConfig.Enabled { // serve the http handler on the selected letsencrypt port, for receiving letsencrypt requests and solving their devious riddles go func() { - if err := http.ListenAndServe(fmt.Sprintf(":%d", r.config.LetsEncryptConfig.Port), r.certManager.HTTPHandler(http.HandlerFunc(httpsRedirect))); err != nil && err != http.ErrServerClosed { + listen := fmt.Sprintf("%s:%d", r.config.BindAddress, r.config.LetsEncryptConfig.Port) + if err := http.ListenAndServe(listen, r.certManager.HTTPHandler(http.HandlerFunc(httpsRedirect))); err != nil && err != http.ErrServerClosed { logrus.Fatalf("listen: %s", err) } }() @@ -138,8 +139,9 @@ func New(ctx context.Context, cfg *config.Config, db db.DB) (Router, error) { } // create the http server here, passing the gin engine as handler + listen := fmt.Sprintf("%s:%d", cfg.BindAddress, cfg.Port) s := &http.Server{ - Addr: fmt.Sprintf(":%d", cfg.Port), + Addr: listen, Handler: engine, ReadTimeout: readTimeout, WriteTimeout: writeTimeout, |