NGINX Configuration
Budget: $25 – $50 USD
ERP System does not URL encode parameters correctly. Need NGINX to parse URI using custom parameter marks, re-rewrite and URL encode to match standards. I have a javascript file that parses the data and rewrites. I need someone to create the NGINX configuration for me.
URL from ERP system
https://redirect.nok.local?/P21Embedded/binqty&rc:Toolbar=false¶ms={LocationID\:1020\,ItemID\:S&DT-RHEE-RTGH-95DVLN-2\}
NGINX re-writes to:
https://rpt.nok.local?/P21Embedded/binqty&rc:toolbar=false&LocationID=1020&ItemID=S%26DT-RHEE-RTGH-95DVLN-2
To parse the "params=" portion, pass to javascript (see below) and it will return the correct url encoded string. Replace the "params=" portion of the URI with the javascript output and proxy to reporting server.
Javascript for parsing "params="
var url = '';
// Make sure string starts with { and ends with \}
if (string.slice(0, 1) == '{' && string.slice(-2) == '\\}') {
// Split string at \,
var data = string.slice(1, string.length - 2).split('\\,');
data.forEach(function(e) {
// Split parts at \:
var pair = e.split('\\:');
// Add & to URL if necessary
url += (url ? '&' : '');
// Add variable=value to URL
url += pair[0] + '=' + encodeURIComponent(pair[1]);
});
}
URL from ERP system
https://redirect.nok.local?/P21Embedded/binqty&rc:Toolbar=false¶ms={LocationID\:1020\,ItemID\:S&DT-RHEE-RTGH-95DVLN-2\}
NGINX re-writes to:
https://rpt.nok.local?/P21Embedded/binqty&rc:toolbar=false&LocationID=1020&ItemID=S%26DT-RHEE-RTGH-95DVLN-2
To parse the "params=" portion, pass to javascript (see below) and it will return the correct url encoded string. Replace the "params=" portion of the URI with the javascript output and proxy to reporting server.
Javascript for parsing "params="
var url = '';
// Make sure string starts with { and ends with \}
if (string.slice(0, 1) == '{' && string.slice(-2) == '\\}') {
// Split string at \,
var data = string.slice(1, string.length - 2).split('\\,');
data.forEach(function(e) {
// Split parts at \:
var pair = e.split('\\:');
// Add & to URL if necessary
url += (url ? '&' : '');
// Add variable=value to URL
url += pair[0] + '=' + encodeURIComponent(pair[1]);
});
}