-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add helper to support TLS #37
Labels
Comments
This is a workaround.
|
Add certmagic to support this feature. // application entrypoint
func main() {
app := macaron.New()
conf.SetupMiddlewares(app)
conf.SetupRoutes(app)
/*
Generated using http://www.kammerl.de/ascii/AsciiSignature.php - (Font: 'starwars')
All signatures are made with FIGlet (c) 1991, 1993, 1994 Glenn Chappell and Ian Chai
All fonts are taken from figlet.org and jave.de.
Please check for Font Credits the figlet font database!
Figlet Frontend - Written by Julius Kammerl - 2005
*/
log.Println(".___ ___. _______ .______ ______ __ __ .______ __ __ __ _______. ___ ___ ")
log.Println("| \\/ | | ____|| _ \\ / || | | | | _ \\ | | | | | | / | / _ \\ / _ ")
log.Println("| \\ / | | |__ | |_) | | ,----'| | | | | |_) | | | | | | | | (----` | | | | | (_) |")
log.Println("| |\\/| | | __| | / | | | | | | | / | | | | | | \\ \\ | | | | > _ < ")
log.Println("| | | | | |____ | |\\ \\----.| `----.| `--' | | |\\ \\----.| | | `--' | .----) | | |_| | _| (_) |")
log.Println("|__| |__| |_______|| _| `._____| \\______| \\______/ | _| `._____||__| \\______/ |_______/ \\___/ (__)___/ ")
var portNumber int
forceLocal, err := config.Cfg.Section("").Key("force_local_http_port").Bool()
if err != nil {
log.Fatalf("Mercurius main - Error checking forceLocal - Error: %s\n", err.Error())
}
if forceLocal {
portNumber, err = config.Cfg.Section("").Key("http_port").Int()
if err != nil {
log.Fatalf("Mercurius main - Error checking local port number to load app - Error: %s\n", err.Error())
}
app.Run(portNumber)
return
}
autoTLSCheck, err := config.Cfg.Section("").Key("auto_tls").Bool()
if err != nil {
log.Fatalf("Mercurius main - Error checking autoTls - Error: %s\n", err.Error())
}
if autoTLSCheck {
dnsServerName := config.Cfg.Section("").Key("dns_server_name").String()
if len(dnsServerName) < 5 {
log.Fatalf("Mercurius main - Error checking dnsServerName - Error: No DNS server name defined\n")
}
log.Println("Loading autotls.Run", dnsServerName, "...")
//This would be an alternative if you want to use letsencrypt app to generate and renew your certs
//http.ListenAndServeTLS(":https", "/etc/letsencrypt/live/example.com/fullchain.pem", "/etc/letsencrypt/live/example.com/privkey.pem", app)
certmagic.Default.Agreed = true
certmagic.Default.Email = "youremail@gmail.com"
certmagic.HTTPS([]string{dnsServerName}, app)
log.Println("Loaded autotls.Run...")
return
}
if portNumber, err = strconv.Atoi(os.Getenv("PORT")); err != nil {
log.Fatalf("Mercurius main - Error checking env port number to load app - Error: %s\n", err.Error())
}
log.Println("Loading portNumber", portNumber, "...")
app.Run(portNumber)
log.Println("Loaded portNumber...")
} app.ini have new fields: oauth_key = 1234567890123456789012345678901212
db_type = mysql
db_user = root
db_pw =
db_name =
db_host = localhost
db_port = 3306
max_conn = 10
idle_conn = 10
cache_adapter = memory
cache_adapter_config =
http_port = 8080
force_local_http_port = false
auto_tls = true
dns_server_name = example.com
mongo_uri = mongodb://localhost:27001/example
mongo_db = example |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add support to obtain from ini file the path for PEM files and if they were set change the app.Run calls to start Macaron with TLS support
The text was updated successfully, but these errors were encountered: