This commit is contained in:
Ali Khamis 2023-03-23 23:31:54 +01:00 committed by GitHub
commit 3a487b8af4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,5 @@
const config = require('config'); const config = require('config');
const fs = require('fs');
if (!config.has('database')) { if (!config.has('database')) {
throw new Error('Database config does not exist! Please read the instructions: https://github.com/jc21/nginx-proxy-manager/blob/master/doc/INSTALL.md'); throw new Error('Database config does not exist! Please read the instructions: https://github.com/jc21/nginx-proxy-manager/blob/master/doc/INSTALL.md');
@ -7,8 +8,8 @@ if (!config.has('database')) {
function generateDbConfig() { function generateDbConfig() {
if (config.database.engine === 'knex-native') { if (config.database.engine === 'knex-native') {
return config.database.knex; return config.database.knex;
} else } else {
return { let newConfig = {
client: config.database.engine, client: config.database.engine,
connection: { connection: {
host: config.database.host, host: config.database.host,
@ -21,6 +22,16 @@ function generateDbConfig() {
tableName: 'migrations' tableName: 'migrations'
} }
}; };
if (process.env.DB_MYSQL_CA) {
newConfig.connection.ssl = {
ca: fs.readFileSync(process.env.DB_MYSQL_CA),
rejectUnauthorized: true
};
}
return newConfig;
}
} }
@ -30,4 +41,4 @@ if (typeof config.database.version !== 'undefined') {
data.version = config.database.version; data.version = config.database.version;
} }
module.exports = require('knex')(data); module.exports = require('knex')(data);