In attempting to run blue-jay/blueprint from Heroku, I cannot bind to port 80 as specified in the .json file, because Heroku seems to dynamically set the ports.
Using os.Getenv("PORT") does not seem to be an option as the .json is a static file.
HTTPPort: env.json
"Server": {
"Hostname": "",
"UseHTTP": true,
"UseHTTPS": false,
"RedirectToHTTPS": false,
"HTTPPort": 80,
"HTTPSPort": 443,
"CertFile": "tls/server.crt",
"KeyFile": "tls/server.key"
},
Returned server error:
server.go:56: listen tcp :80: bind: permission denied
Sources:
https://github.com/blue-jay/blueprint/blob/master/env.json.example
https://github.com/blue-jay/blueprint
What is an appropriate way to handle this?
True, you cannot set the port on Heroku. You have to deal with their port. I'd recommend to modify blueprint.go
right before you run the server
port := os.Getenv("PORT")
if port == "" {
log.Fatal("$PORT must be set")
}
config.Server.HTTPPort, _ = strconv.Atoi(port)
// Start the HTTP and HTTPS listeners
server.Run(
handler, // HTTP handler
handler, // HTTPS handler
config.Server, // Server settings
)