Skip to content
Michael VERGOZ edited this page Aug 26, 2014 · 2 revisions

Here is a configuration example for the executer opcode :

var serverConfig = function(bs) { return({
	serverProcess: 4,
	hostname: "testServer0",
	runDir: "/var/run/gatejs",
	dataDir: "/home/gatejs-data",
	logDir: "/var/log/gatejs",
	confDir: '/etc/gatejs',
	
	http: {
		forwardInterface: {
			type: 'forward',
			port: 80,
			pipeline: 'pipetest'
		}
	},
	
	pipeline: {
		pipetest: [
			['executer', function(pipe) {
				if(pipe.request.headers.host.match(/^wpad(:[0-9]+)?$/)) {
					pipe.stop();
					pipe.response.setHeader("Content-Type", "application/x-ns-proxy-autoconfig");
					pipe.response.write(
						'function FindProxyForURL(url, host) {\n' +
						'	return "PROXY wpad:80; DIRECT";\n' +
						'}'
					);
					pipe.response.end();
				}
			}],
			['cache', { }],
			['proxyPass', { mode: 'host', timeout: 10 }]
		],
	}
	
})};

module.exports = serverConfig;

Here, the request is catched first with executer, and if the host is "wpad", a specific response is sent.

It may be used as-is for an automatic forward proxy in a LAN. See Web_Proxy_Autodiscovery_Protocol and Proxy_auto-config

Clone this wiki locally