mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-11 02:12:53 +00:00
adding tls
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,3 +6,5 @@ dist
|
|||||||
public
|
public
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
mywebsite
|
mywebsite
|
||||||
|
tls.key
|
||||||
|
tls.crt
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
{
|
{
|
||||||
"database": {
|
"Database": {
|
||||||
"url": "",
|
"url": "",
|
||||||
"database": "",
|
"database": "",
|
||||||
"username": "",
|
"username": "",
|
||||||
"password": ""
|
"password": ""
|
||||||
},
|
},
|
||||||
"api": {
|
"Api": {
|
||||||
"key": ""
|
"key": ""
|
||||||
},
|
},
|
||||||
"port": 8080
|
"Port": 8080,
|
||||||
|
"TLSPort": 443,
|
||||||
|
"TLSCertFile": "",
|
||||||
|
"TLSKeyFile": ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"check-gzip-size": "gzip -9 -c ./public/client.min.js | wc -c | numfmt --to=iec-i --suffix=B --padding=10",
|
"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",
|
"deploy": "npm run get_dependencies && npm run prod && ./mywebsite",
|
||||||
"dev": "webpack-dev-server --content-base public --inline --hot --history-api-fallback",
|
"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",
|
"get_dependencies": "go get ./server && npm install",
|
||||||
"prod": "npm run build && go build ./server/mywebsite.go",
|
"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",
|
"prod-win": "webpack -p --define process.env.NODE_ENV='\"production\"' --progress --colors && babel-node metadata.js && go build ./server/mywebsite.go",
|
||||||
|
|||||||
@@ -24,5 +24,11 @@ func main(){
|
|||||||
handle := gziphandler.GzipHandler(route.Routes())
|
handle := gziphandler.GzipHandler(route.Routes())
|
||||||
|
|
||||||
log.Println("Starting Server...")
|
log.Println("Starting Server...")
|
||||||
log.Println(http.ListenAndServe(":"+strconv.Itoa(configurations.Port), handle))
|
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))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,12 @@ import (
|
|||||||
|
|
||||||
//structure for application configurations
|
//structure for application configurations
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Database db.DatabaseInfo `json:"database"`
|
Database db.DatabaseInfo `json:"Database"`
|
||||||
Api api.ApiInfo `json:"api"`
|
Api api.ApiInfo `json:"Api"`
|
||||||
Port int `json:"port"`
|
Port int `json:"Port"`
|
||||||
|
TLSPort int `json:"TLSPort"`
|
||||||
|
TLSCertFile string `json:"TLSCertFile"`
|
||||||
|
TLSKeyFile string `json:"TLSKeyFile"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//read the config file and return JsonObject struct
|
//read the config file and return JsonObject struct
|
||||||
|
|||||||
Reference in New Issue
Block a user