mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-10 09:52:51 +00:00
adding tls
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -5,4 +5,6 @@ node_modules
|
||||
dist
|
||||
public
|
||||
npm-debug.log
|
||||
mywebsite
|
||||
mywebsite
|
||||
tls.key
|
||||
tls.crt
|
||||
@@ -1,12 +1,15 @@
|
||||
{
|
||||
"database": {
|
||||
"Database": {
|
||||
"url": "",
|
||||
"database": "",
|
||||
"username": "",
|
||||
"password": ""
|
||||
},
|
||||
"api": {
|
||||
"Api": {
|
||||
"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",
|
||||
"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",
|
||||
|
||||
@@ -24,5 +24,11 @@ func main(){
|
||||
handle := gziphandler.GzipHandler(route.Routes())
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user