✨ Auto Redirect
All checks were successful
release-nightly / build-docker (push) Successful in 3m33s
All checks were successful
release-nightly / build-docker (push) Successful in 3m33s
This commit is contained in:
parent
90ac125886
commit
9a5c5e9fca
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
/config
|
||||
/letsencrypt
|
@ -2,6 +2,7 @@ package hypertext
|
||||
|
||||
import (
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
@ -46,8 +47,23 @@ func RunServer(app *fiber.App, ports []string, securedPorts []string, pem string
|
||||
for _, port := range ports {
|
||||
port := port
|
||||
go func() {
|
||||
if err := app.Listen(port); err != nil {
|
||||
log.Panic().Err(err).Msg("An error occurred when listening hypertext tls ports.")
|
||||
if viper.GetBool("hypertext.certificate.redirect") {
|
||||
redirector := fiber.New(fiber.Config{
|
||||
AppName: "RoadSign",
|
||||
ServerHeader: "RoadSign",
|
||||
DisableStartupMessage: true,
|
||||
EnableIPValidation: true,
|
||||
})
|
||||
redirector.All("/", func(c *fiber.Ctx) error {
|
||||
return c.Redirect(strings.ReplaceAll(string(c.Request().URI().FullURI()), "http", "https"))
|
||||
})
|
||||
if err := redirector.Listen(port); err != nil {
|
||||
log.Panic().Err(err).Msg("An error occurred when listening hypertext common ports.")
|
||||
}
|
||||
} else {
|
||||
if err := app.Listen(port); err != nil {
|
||||
log.Panic().Err(err).Msg("An error occurred when listening hypertext common ports.")
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
45
settings.yml
45
settings.yml
@ -1,27 +1,28 @@
|
||||
debug:
|
||||
print_routes: true
|
||||
print_routes: true
|
||||
hypertext:
|
||||
sideload_ports:
|
||||
- :81
|
||||
sideload_secured_ports: []
|
||||
certificate:
|
||||
sideload_key: ./cert.key
|
||||
sideload_pem: ./cert.pem
|
||||
key: ./cert.key
|
||||
pem: ./cert.pem
|
||||
limitation:
|
||||
max_body_size: 536870912
|
||||
max_qps: -1
|
||||
ports:
|
||||
- :8000
|
||||
secured_ports: []
|
||||
sideload_ports:
|
||||
- :81
|
||||
sideload_secured_ports: [ ]
|
||||
certificate:
|
||||
redirect: false
|
||||
sideload_key: ./cert.key
|
||||
sideload_pem: ./cert.pem
|
||||
key: ./cert.key
|
||||
pem: ./cert.pem
|
||||
limitation:
|
||||
max_body_size: 536870912
|
||||
max_qps: -1
|
||||
ports:
|
||||
- :8000
|
||||
secured_ports: [ ]
|
||||
paths:
|
||||
configs: ./config
|
||||
configs: ./config
|
||||
performance:
|
||||
request_logging: true
|
||||
network_timeout: 3000
|
||||
prefork: false
|
||||
request_logging: true
|
||||
network_timeout: 3000
|
||||
prefork: false
|
||||
security:
|
||||
sideload_trusted_proxies:
|
||||
- localhost
|
||||
credential: e81f43f32d934271af6322e5376f5f59
|
||||
sideload_trusted_proxies:
|
||||
- localhost
|
||||
credential: e81f43f32d934271af6322e5376f5f59
|
||||
|
Loading…
Reference in New Issue
Block a user