Skip to content

Commit a9ca952

Browse files
committed
not working - add PROXY to stream hosts. migration and db fix script
1 parent 5970b74 commit a9ca952

File tree

6 files changed

+91
-145
lines changed

6 files changed

+91
-145
lines changed

backend/migrations/20220209144645_proxy_protocol.js

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
const migrate_name = 'stream_proxy_protocol';
2+
const logger = require('../logger').migrate;
3+
4+
/**
5+
* Migrate
6+
*
7+
* @see http://knexjs.org/#Schema
8+
*
9+
* @param {Object} knex
10+
* @param {Promise} Promise
11+
* @returns {Promise}
12+
*/
13+
exports.up = function (knex/*, Promise*/) {
14+
knex.schema.table('stream', function (stream) {
15+
stream.dropColumn('stream_access_proxy_protocol');
16+
})
17+
.then(() => {
18+
logger.info('[' + migrate_name + '] stream Table altered - ERRANT Column fixed!');
19+
}).catch((err) => {
20+
logger.error('[' + migrate_name + '] stream Table error while removing errant column: ' + err);
21+
});
22+
23+
logger.info('[' + migrate_name + '] Migrating PROXY_HOST Table Up...');
24+
knex.schema.table('proxy_host', function (proxy_host) {
25+
proxy_host.integer('enable_proxy_protocol').notNull().unsigned().defaultTo(0);
26+
})
27+
.then(() => {
28+
logger.info('[' + migrate_name + '] proxy_host Table altered - "enable_proxy_protocol" added');
29+
}).catch((err) => {
30+
logger.error('[' + migrate_name + '] proxy_host Table error migrating up: ' + err);
31+
});
32+
knex.schema.table('proxy_host', function (proxy_host) {
33+
proxy_host.string('load_balancer_ip').notNull().defaultTo('');
34+
})
35+
.then(() => {
36+
logger.info('[' + migrate_name + '] proxy_host Table altered - "load_balancer_ip" added');
37+
}).catch((err) => {
38+
logger.error('[' + migrate_name + '] proxy_host Table error migrating up: ' + err);
39+
});
40+
41+
logger.info('[' + migrate_name + '] Migrating STREAM Table Up...');
42+
knex.schema.table('stream', function (stream) {
43+
stream.integer('stream_allow_proxy_protocol').notNull().unsigned().defaultTo(0);
44+
})
45+
.then(() => {
46+
logger.info('[' + migrate_name + '] stream Table altered - PROXY protocol added');
47+
}).catch((err) => {
48+
logger.error('[' + migrate_name + '] stream Table error migrating up: ' + err);
49+
});
50+
knex.schema.table('stream', function (stream) {
51+
stream.integer('stream_enable_proxy_protocol').notNull().unsigned().defaultTo(0);
52+
})
53+
.then(() => {
54+
logger.info('[' + migrate_name + '] stream Table altered - PROXY protocol added');
55+
}).catch((err) => {
56+
logger.error('[' + migrate_name + '] stream Table error migrating up: ' + err);
57+
});
58+
knex.schema.table('stream', function (stream) {
59+
stream.integer('stream_load_balancer_ip').notNull().unsigned().defaultTo('');
60+
})
61+
.then(() => {
62+
logger.info('[' + migrate_name + '] stream Table altered - PROXY protocol added');
63+
}).catch((err) => {
64+
logger.error('[' + migrate_name + '] stream Table error migrating up: ' + err);
65+
});
66+
return Promise.resolve(true);
67+
};
68+
69+
/**
70+
* Undo Migrate
71+
*
72+
* @param {Object} knex
73+
* @param {Promise} Promise
74+
* @returns {Promise}
75+
*/
76+
exports.down = function (knex, Promise) {
77+
logger.warn('[' + migrate_name + '] You can\'t migrate down this one.');
78+
return Promise.resolve(true);
79+
};

backend/migrations/22021009153423_proxy_protocol.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

backend/migrations/22021010135303_stream_proxy_protocol.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

frontend/js/app/nginx/stream/form.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<label class="custom-switch">
4848
<input type="checkbox" class="custom-switch-input" name="stream_enable_proxy_protocol" value="1"<%- stream_enable_proxy_protocol ? ' checked' : '' %>>
4949
<span class="custom-switch-indicator"></span>
50-
<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>
50+
<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>
5151
</label>
5252
</div>
5353
</div>
@@ -56,7 +56,7 @@
5656
<label class="custom-switch">
5757
<input type="checkbox" class="custom-switch-input" name="stream_allow_proxy_protocol" value="1"<%- stream_allow_proxy_protocol ? ' checked' : '' %>>
5858
<span class="custom-switch-indicator"></span>
59-
<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>
59+
<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>
6060
</label>
6161
</div>
6262
</div>

scripts/npm_db_fix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env sh
2+
log() {
3+
echo -e "[$(basename "$0")]> $*"
4+
}
5+
log "Executing SQL migration fixes"
6+
mysql -u root -p"${MYSQL_ROOT_PASSWORD}" -D "${MYSQL_DATABASE}" -e "DELETE from migrations where name = '20220209144645_proxy_protocol.js';"
7+
mysql -u root -p"${MYSQL_ROOT_PASSWORD}" -D "${MYSQL_DATABASE}" -e "DELETE from migrations where name = '22021009153423_proxy_protocol.js';"
8+
mysql -u root -p"${MYSQL_ROOT_PASSWORD}" -D "${MYSQL_DATABASE}" -e "DELETE from migrations where name = '22021010135303_stream_proxy_protocol.js';"
9+
mysql -u root -p"${MYSQL_ROOT_PASSWORD}" -D "${MYSQL_DATABASE}" -e "DELETE from migrations where name = '22021010135304_stream_proxy_protocol.js';"
10+
mysql -u root -p"${MYSQL_ROOT_PASSWORD}" -D "${MYSQL_DATABASE}" -e "DELETE from migrations where name = '20221010135304_stream_proxy_protocol.js';"

0 commit comments

Comments
 (0)