@@ -11,6 +11,8 @@ import (
11
11
"github.com/golang/glog"
12
12
)
13
13
14
+ const dhparamFilename = "dhparam.pem"
15
+
14
16
// NginxController Updates NGINX configuration, starts and reloads NGINX
15
17
type NginxController struct {
16
18
nginxConfdPath string
@@ -70,6 +72,11 @@ type NginxMainConfig struct {
70
72
ServerNamesHashBucketSize string
71
73
ServerNamesHashMaxSize string
72
74
LogFormat string
75
+ // http://nginx.org/en/docs/http/ngx_http_ssl_module.html
76
+ SSLProtocols string
77
+ SSLPreferServerCiphers bool
78
+ SSLCiphers string
79
+ SSLDHParam string
73
80
}
74
81
75
82
// NewUpstreamWithDefaultServer creates an upstream with the default server.
@@ -91,7 +98,7 @@ func NewNginxController(nginxConfPath string, local bool) (*NginxController, err
91
98
}
92
99
93
100
if ! local {
94
- ngxc .createCertsDir ( )
101
+ createDir ( ngxc .nginxCertsPath )
95
102
}
96
103
97
104
cfg := & NginxMainConfig {ServerNamesHashMaxSize : NewDefaultConfig ().MainServerNamesHashMaxSize }
@@ -121,6 +128,24 @@ func (nginx *NginxController) AddOrUpdateIngress(name string, config IngressNgin
121
128
nginx .templateIt (config , filename )
122
129
}
123
130
131
+ // AddOrUpdateDHParam creates the servers dhparam.pem file
132
+ func (nginx * NginxController ) AddOrUpdateDHParam (dhparam string ) (string , error ) {
133
+ fileName := nginx .nginxCertsPath + "/" + dhparamFilename
134
+ if ! nginx .local {
135
+ pem , err := os .Create (fileName )
136
+ if err != nil {
137
+ return fileName , fmt .Errorf ("Couldn't create file %v: %v" , fileName , err )
138
+ }
139
+ defer pem .Close ()
140
+
141
+ _ , err = pem .WriteString (dhparam )
142
+ if err != nil {
143
+ return fileName , fmt .Errorf ("Couldn't write to pem file %v: %v" , fileName , err )
144
+ }
145
+ }
146
+ return fileName , nil
147
+ }
148
+
124
149
// AddOrUpdateCertAndKey creates a .pem file wth the cert and the key with the
125
150
// specified name
126
151
func (nginx * NginxController ) AddOrUpdateCertAndKey (name string , cert string , key string ) string {
@@ -211,9 +236,9 @@ func (nginx *NginxController) Start() {
211
236
}
212
237
}
213
238
214
- func ( nginx * NginxController ) createCertsDir ( ) {
215
- if err := os .Mkdir (nginx . nginxCertsPath , os .ModeDir ); err != nil {
216
- glog .Fatalf ("Couldn't create directory %v: %v" , nginx . nginxCertsPath , err )
239
+ func createDir ( path string ) {
240
+ if err := os .Mkdir (path , os .ModeDir ); err != nil {
241
+ glog .Fatalf ("Couldn't create directory %v: %v" , path , err )
217
242
}
218
243
}
219
244
0 commit comments