✨ 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
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
/config
|
/config
|
||||||
|
/letsencrypt
|
@ -2,6 +2,7 @@ package hypertext
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
@ -46,8 +47,23 @@ func RunServer(app *fiber.App, ports []string, securedPorts []string, pem string
|
|||||||
for _, port := range ports {
|
for _, port := range ports {
|
||||||
port := port
|
port := port
|
||||||
go func() {
|
go func() {
|
||||||
if err := app.Listen(port); err != nil {
|
if viper.GetBool("hypertext.certificate.redirect") {
|
||||||
log.Panic().Err(err).Msg("An error occurred when listening hypertext tls ports.")
|
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:
|
debug:
|
||||||
print_routes: true
|
print_routes: true
|
||||||
hypertext:
|
hypertext:
|
||||||
sideload_ports:
|
sideload_ports:
|
||||||
- :81
|
- :81
|
||||||
sideload_secured_ports: []
|
sideload_secured_ports: [ ]
|
||||||
certificate:
|
certificate:
|
||||||
sideload_key: ./cert.key
|
redirect: false
|
||||||
sideload_pem: ./cert.pem
|
sideload_key: ./cert.key
|
||||||
key: ./cert.key
|
sideload_pem: ./cert.pem
|
||||||
pem: ./cert.pem
|
key: ./cert.key
|
||||||
limitation:
|
pem: ./cert.pem
|
||||||
max_body_size: 536870912
|
limitation:
|
||||||
max_qps: -1
|
max_body_size: 536870912
|
||||||
ports:
|
max_qps: -1
|
||||||
- :8000
|
ports:
|
||||||
secured_ports: []
|
- :8000
|
||||||
|
secured_ports: [ ]
|
||||||
paths:
|
paths:
|
||||||
configs: ./config
|
configs: ./config
|
||||||
performance:
|
performance:
|
||||||
request_logging: true
|
request_logging: true
|
||||||
network_timeout: 3000
|
network_timeout: 3000
|
||||||
prefork: false
|
prefork: false
|
||||||
security:
|
security:
|
||||||
sideload_trusted_proxies:
|
sideload_trusted_proxies:
|
||||||
- localhost
|
- localhost
|
||||||
credential: e81f43f32d934271af6322e5376f5f59
|
credential: e81f43f32d934271af6322e5376f5f59
|
||||||
|
Loading…
Reference in New Issue
Block a user