mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-08-21 00:17:38 +00:00
not working - add PROXY to stream hosts. migration and db fix script
This commit is contained in:
@@ -1,44 +0,0 @@
|
|||||||
const migrate_name = 'proxy_protocol';
|
|
||||||
const logger = require('../logger').migrate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Migrate
|
|
||||||
*
|
|
||||||
* @see http://knexjs.org/#Schema
|
|
||||||
*
|
|
||||||
* @param {Object} knex
|
|
||||||
* @param {Promise} Promise
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
|
||||||
exports.up = function (knex/*, Promise*/) {
|
|
||||||
logger.info('[' + migrate_name + '] Migrating Up...');
|
|
||||||
|
|
||||||
return knex.schema.table('proxy_host', function (proxy_host) {
|
|
||||||
proxy_host.integer('enable_proxy_protocol').notNull().unsigned().defaultTo(0);
|
|
||||||
proxy_host.string('load_balancer_ip').notNull().defaultTo('');
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
logger.info('[' + migrate_name + '] proxy_host Table altered');
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Undo Migrate
|
|
||||||
*
|
|
||||||
* @param {Object} knex
|
|
||||||
* @param {Promise} Promise
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
|
||||||
exports.down = function (knex/*, Promise*/) {
|
|
||||||
return knex.schema.table('proxy_host', (proxy_host) => {
|
|
||||||
proxy_host.dropColumn('enable_proxy_protocol');
|
|
||||||
proxy_host.dropColumn('load_balancer_ip');
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
logger.info('[' + migrate_name + '] MIGRATING DOWN proxy_host Table altered');
|
|
||||||
});
|
|
||||||
|
|
||||||
// logger.warn('[' + migrate_name + '] You can\'t migrate down this one.');
|
|
||||||
// return Promise.resolve(true);
|
|
||||||
};
|
|
79
backend/migrations/20221011000001_stream_proxy_protocol.js
Normal file
79
backend/migrations/20221011000001_stream_proxy_protocol.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
const migrate_name = 'stream_proxy_protocol';
|
||||||
|
const logger = require('../logger').migrate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrate
|
||||||
|
*
|
||||||
|
* @see http://knexjs.org/#Schema
|
||||||
|
*
|
||||||
|
* @param {Object} knex
|
||||||
|
* @param {Promise} Promise
|
||||||
|
* @returns {Promise}
|
||||||
|
*/
|
||||||
|
exports.up = function (knex/*, Promise*/) {
|
||||||
|
knex.schema.table('stream', function (stream) {
|
||||||
|
stream.dropColumn('stream_access_proxy_protocol');
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
logger.info('[' + migrate_name + '] stream Table altered - ERRANT Column fixed!');
|
||||||
|
}).catch((err) => {
|
||||||
|
logger.error('[' + migrate_name + '] stream Table error while removing errant column: ' + err);
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.info('[' + migrate_name + '] Migrating PROXY_HOST Table Up...');
|
||||||
|
knex.schema.table('proxy_host', function (proxy_host) {
|
||||||
|
proxy_host.integer('enable_proxy_protocol').notNull().unsigned().defaultTo(0);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
logger.info('[' + migrate_name + '] proxy_host Table altered - "enable_proxy_protocol" added');
|
||||||
|
}).catch((err) => {
|
||||||
|
logger.error('[' + migrate_name + '] proxy_host Table error migrating up: ' + err);
|
||||||
|
});
|
||||||
|
knex.schema.table('proxy_host', function (proxy_host) {
|
||||||
|
proxy_host.string('load_balancer_ip').notNull().defaultTo('');
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
logger.info('[' + migrate_name + '] proxy_host Table altered - "load_balancer_ip" added');
|
||||||
|
}).catch((err) => {
|
||||||
|
logger.error('[' + migrate_name + '] proxy_host Table error migrating up: ' + err);
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.info('[' + migrate_name + '] Migrating STREAM Table Up...');
|
||||||
|
knex.schema.table('stream', function (stream) {
|
||||||
|
stream.integer('stream_allow_proxy_protocol').notNull().unsigned().defaultTo(0);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
logger.info('[' + migrate_name + '] stream Table altered - PROXY protocol added');
|
||||||
|
}).catch((err) => {
|
||||||
|
logger.error('[' + migrate_name + '] stream Table error migrating up: ' + err);
|
||||||
|
});
|
||||||
|
knex.schema.table('stream', function (stream) {
|
||||||
|
stream.integer('stream_enable_proxy_protocol').notNull().unsigned().defaultTo(0);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
logger.info('[' + migrate_name + '] stream Table altered - PROXY protocol added');
|
||||||
|
}).catch((err) => {
|
||||||
|
logger.error('[' + migrate_name + '] stream Table error migrating up: ' + err);
|
||||||
|
});
|
||||||
|
knex.schema.table('stream', function (stream) {
|
||||||
|
stream.integer('stream_load_balancer_ip').notNull().unsigned().defaultTo('');
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
logger.info('[' + migrate_name + '] stream Table altered - PROXY protocol added');
|
||||||
|
}).catch((err) => {
|
||||||
|
logger.error('[' + migrate_name + '] stream Table error migrating up: ' + err);
|
||||||
|
});
|
||||||
|
return Promise.resolve(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undo Migrate
|
||||||
|
*
|
||||||
|
* @param {Object} knex
|
||||||
|
* @param {Promise} Promise
|
||||||
|
* @returns {Promise}
|
||||||
|
*/
|
||||||
|
exports.down = function (knex, Promise) {
|
||||||
|
logger.warn('[' + migrate_name + '] You can\'t migrate down this one.');
|
||||||
|
return Promise.resolve(true);
|
||||||
|
};
|
@@ -1,50 +0,0 @@
|
|||||||
const migrate_name = 'proxy_protocol';
|
|
||||||
const logger = require('../logger').migrate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Migrate
|
|
||||||
*
|
|
||||||
* @see http://knexjs.org/#Schema
|
|
||||||
*
|
|
||||||
* @param {Object} knex
|
|
||||||
* @param {Promise} Promise
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
|
||||||
exports.up = function (knex/*, Promise*/) {
|
|
||||||
logger.info('[' + migrate_name + '] Migrating Up...');
|
|
||||||
let ret = knex.schema.table('proxy_host', function (proxy_host) {
|
|
||||||
proxy_host.integer('enable_proxy_protocol').notNull().unsigned().defaultTo(0);
|
|
||||||
proxy_host.string('load_balancer_ip').notNull().defaultTo('');
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
logger.info('[' + migrate_name + '] proxy_host Table altered - PROXY protocol added');
|
|
||||||
}).catch((err) => {
|
|
||||||
logger.error('[' + migrate_name + '] Error migrating up: ' + err);
|
|
||||||
ret = Promise.resolve(true);
|
|
||||||
});
|
|
||||||
if (!ret) {
|
|
||||||
logger.error('[' + migrate_name + '] ERROR MIGRATING UP');
|
|
||||||
ret = Promise.resolve(true);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Undo Migrate
|
|
||||||
*
|
|
||||||
* @param {Object} knex
|
|
||||||
* @param {Promise} Promise
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
|
||||||
exports.down = function (knex/*, Promise*/) {
|
|
||||||
return knex.schema.table('proxy_host', (proxy_host) => {
|
|
||||||
proxy_host.dropColumn('enable_proxy_protocol');
|
|
||||||
proxy_host.dropColumn('load_balancer_ip');
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
logger.info('[' + migrate_name + '] MIGRATING DOWN proxy_host Table altered - PROXY protocol removed');
|
|
||||||
});
|
|
||||||
|
|
||||||
// logger.warn('[' + migrate_name + '] You can\'t migrate down this one.');
|
|
||||||
// return Promise.resolve(true);
|
|
||||||
};
|
|
@@ -1,49 +0,0 @@
|
|||||||
const migrate_name = 'stream_proxy_protocol';
|
|
||||||
const logger = require('../logger').migrate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Migrate
|
|
||||||
*
|
|
||||||
* @see http://knexjs.org/#Schema
|
|
||||||
*
|
|
||||||
* @param {Object} knex
|
|
||||||
* @param {Promise} Promise
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
|
||||||
exports.up = function (knex/*, Promise*/) {
|
|
||||||
logger.info('[' + migrate_name + '] Migrating Up...');
|
|
||||||
let ret = knex.schema.table('stream', function (stream) {
|
|
||||||
stream.integer('stream_enable_proxy_protocol').notNull().unsigned().defaultTo(0);
|
|
||||||
stream.integer('stream_access_proxy_protocol').notNull().unsigned().defaultTo(0);
|
|
||||||
stream.string('stream_load_balancer_ip').notNull().defaultTo('');
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
logger.info('[' + migrate_name + '] stream Table altered - PROXY protocol added');
|
|
||||||
}).catch((err) => {
|
|
||||||
logger.error('[' + migrate_name + '] Error migrating up: ' + err);
|
|
||||||
});
|
|
||||||
if (!ret) {
|
|
||||||
logger.error('[' + migrate_name + '] ERROR MIGRATING UP');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Undo Migrate
|
|
||||||
*
|
|
||||||
* @param {Object} knex
|
|
||||||
* @param {Promise} Promise
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
|
||||||
exports.down = function (knex/*, Promise*/) {
|
|
||||||
return knex.schema.table('stream', (stream) => {
|
|
||||||
stream.dropColumn('stream_enable_proxy_protocol');
|
|
||||||
stream.dropColumn('stream_access_proxy_protocol');
|
|
||||||
stream.dropColumn('stream_load_balancer_ip');
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
logger.info('[' + migrate_name + '] MIGRATING DOWN stream Table altered - PROXY protocol removed');
|
|
||||||
});
|
|
||||||
|
|
||||||
// logger.warn('[' + migrate_name + '] You can\'t migrate down this one.');
|
|
||||||
// return Promise.resolve(true);
|
|
||||||
};
|
|
@@ -47,7 +47,7 @@
|
|||||||
<label class="custom-switch">
|
<label class="custom-switch">
|
||||||
<input type="checkbox" class="custom-switch-input" name="stream_enable_proxy_protocol" value="1"<%- stream_enable_proxy_protocol ? ' checked' : '' %>>
|
<input type="checkbox" class="custom-switch-input" name="stream_enable_proxy_protocol" value="1"<%- stream_enable_proxy_protocol ? ' checked' : '' %>>
|
||||||
<span class="custom-switch-indicator"></span>
|
<span class="custom-switch-indicator"></span>
|
||||||
<span class="custom-switch-description"><%- i18n('streams', 'enable_proxy_protocol') %><a href="https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol/#proxy-protocol-for-a-tcp-connection-to-an-upstream" target="_blank"><i class="fe fe-help-circle"></i></a></span>
|
<span class="custom-switch-description"><%- i18n('streams', 'enable-proxy-protocol') %><a href="https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol/#proxy-protocol-for-a-tcp-connection-to-an-upstream" target="_blank"><i class="fe fe-help-circle"></i></a></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
<label class="custom-switch">
|
<label class="custom-switch">
|
||||||
<input type="checkbox" class="custom-switch-input" name="stream_allow_proxy_protocol" value="1"<%- stream_allow_proxy_protocol ? ' checked' : '' %>>
|
<input type="checkbox" class="custom-switch-input" name="stream_allow_proxy_protocol" value="1"<%- stream_allow_proxy_protocol ? ' checked' : '' %>>
|
||||||
<span class="custom-switch-indicator"></span>
|
<span class="custom-switch-indicator"></span>
|
||||||
<span class="custom-switch-description"><%- i18n('streams', 'allow_proxy_protocol') %> <a href="https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol/#introduction" target="_blank"><i class="fe fe-help-circle"></i></a></span>
|
<span class="custom-switch-description"><%- i18n('streams', 'allow-proxy-protocol') %> <a href="https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol/#introduction" target="_blank"><i class="fe fe-help-circle"></i></a></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
10
scripts/npm_db_fix
Executable file
10
scripts/npm_db_fix
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
log() {
|
||||||
|
echo -e "[$(basename "$0")]> $*"
|
||||||
|
}
|
||||||
|
log "Executing SQL migration fixes"
|
||||||
|
mysql -u root -p"${MYSQL_ROOT_PASSWORD}" -D "${MYSQL_DATABASE}" -e "DELETE from migrations where name = '20220209144645_proxy_protocol.js';"
|
||||||
|
mysql -u root -p"${MYSQL_ROOT_PASSWORD}" -D "${MYSQL_DATABASE}" -e "DELETE from migrations where name = '22021009153423_proxy_protocol.js';"
|
||||||
|
mysql -u root -p"${MYSQL_ROOT_PASSWORD}" -D "${MYSQL_DATABASE}" -e "DELETE from migrations where name = '22021010135303_stream_proxy_protocol.js';"
|
||||||
|
mysql -u root -p"${MYSQL_ROOT_PASSWORD}" -D "${MYSQL_DATABASE}" -e "DELETE from migrations where name = '22021010135304_stream_proxy_protocol.js';"
|
||||||
|
mysql -u root -p"${MYSQL_ROOT_PASSWORD}" -D "${MYSQL_DATABASE}" -e "DELETE from migrations where name = '20221010135304_stream_proxy_protocol.js';"
|
Reference in New Issue
Block a user