1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-10 09:52:51 +00:00

adding tls

This commit is contained in:
2016-10-28 21:27:04 +02:00
parent 6848ddadd0
commit 9c2e7bd754
5 changed files with 23 additions and 8 deletions

2
.gitignore vendored
View File

@@ -6,3 +6,5 @@ dist
public
npm-debug.log
mywebsite
tls.key
tls.crt

View File

@@ -1,12 +1,15 @@
{
"database": {
"Database": {
"url": "",
"database": "",
"username": "",
"password": ""
},
"api": {
"Api": {
"key": ""
},
"port": 8080
"Port": 8080,
"TLSPort": 443,
"TLSCertFile": "",
"TLSKeyFile": ""
}

View File

@@ -10,6 +10,7 @@
"check-gzip-size": "gzip -9 -c ./public/client.min.js | wc -c | numfmt --to=iec-i --suffix=B --padding=10",
"deploy": "npm run get_dependencies && npm run prod && ./mywebsite",
"dev": "webpack-dev-server --content-base public --inline --hot --history-api-fallback",
"generate-tls": "sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./tls.key -out ./tls.crt",
"get_dependencies": "go get ./server && npm install",
"prod": "npm run build && go build ./server/mywebsite.go",
"prod-win": "webpack -p --define process.env.NODE_ENV='\"production\"' --progress --colors && babel-node metadata.js && go build ./server/mywebsite.go",

View File

@@ -24,5 +24,11 @@ func main(){
handle := gziphandler.GzipHandler(route.Routes())
log.Println("Starting Server...")
go func(){
log.Println(http.ListenAndServe(":"+strconv.Itoa(configurations.Port), handle))
}()
if configurations.TLSCertFile != "" && configurations.TLSKeyFile != "" {
log.Println(http.ListenAndServeTLS(":"+strconv.Itoa(configurations.TLSPort), configurations.TLSCertFile, configurations.TLSKeyFile, handle))
}
}

View File

@@ -12,9 +12,12 @@ import (
//structure for application configurations
type Config struct {
Database db.DatabaseInfo `json:"database"`
Api api.ApiInfo `json:"api"`
Port int `json:"port"`
Database db.DatabaseInfo `json:"Database"`
Api api.ApiInfo `json:"Api"`
Port int `json:"Port"`
TLSPort int `json:"TLSPort"`
TLSCertFile string `json:"TLSCertFile"`
TLSKeyFile string `json:"TLSKeyFile"`
}
//read the config file and return JsonObject struct