@@ -16,6 +16,7 @@ const {
1616 PROMETHEUS_WITH_METHOD = 'true' ,
1717 PROMETHEUS_WITH_STATUS = 'true' ,
1818 PROMETHEUS_METRIC_TYPE = 'summary' ,
19+ MAX_HEADER_SIZE = 1048576
1920} = process . env
2021
2122const sleep = promisify ( setTimeout ) ;
@@ -189,22 +190,27 @@ app.all('*', (req, res) => {
189190
190191} ) ;
191192
192- let sslOpts = {
193+ let httpOpts = {
194+ maxHeaderSize : process . env . MAX_HEADER_SIZE
195+ }
196+
197+ let httpsOpts = {
193198 key : require ( 'fs' ) . readFileSync ( process . env . HTTPS_KEY_FILE || 'privkey.pem' ) ,
194- cert : require ( 'fs' ) . readFileSync ( process . env . HTTPS_CERT_FILE || 'fullchain.pem' )
199+ cert : require ( 'fs' ) . readFileSync ( process . env . HTTPS_CERT_FILE || 'fullchain.pem' ) ,
200+ maxHeaderSize : process . env . MAX_HEADER_SIZE
195201} ;
196202
197203//Whether to enable the client certificate feature
198204if ( process . env . MTLS_ENABLE ) {
199- sslOpts = {
205+ httpsOpts = {
200206 requestCert : true ,
201207 rejectUnauthorized : false ,
202- ...sslOpts
208+ ...httpsOpts
203209 }
204210}
205211
206- var httpServer = http . createServer ( app ) . listen ( process . env . HTTP_PORT || 8080 ) ;
207- var httpsServer = https . createServer ( sslOpts , app ) . listen ( process . env . HTTPS_PORT || 8443 ) ;
212+ var httpServer = http . createServer ( httpOpts , app ) . listen ( process . env . HTTP_PORT || 8080 ) ;
213+ var httpsServer = https . createServer ( httpsOpts , app ) . listen ( process . env . HTTPS_PORT || 8443 ) ;
208214console . log ( `Listening on ports ${ process . env . HTTP_PORT || 8080 } for http, and ${ process . env . HTTPS_PORT || 8443 } for https.` ) ;
209215
210216let calledClose = false ;
0 commit comments