-
Notifications
You must be signed in to change notification settings - Fork 15
ConfigurationHttpReverse
HTTP reverse proxys are defined globally in configuration as http sub-object. The major difference between forward & reverse proxy is that reverse mode well knowns websites passing. Then, in case of using reverse proxy you will have to define websites. Website creation is explained below.
As forward proxy, reverse proxy needs a global configuration.
Here is a base example:
var serverConfig = function(bs) { return({
serverProcess: 4,
hostname: "testServer0",
runDir: "/tmp/gatejs",
dataDir: "/path/to/dataDir",
logDir: "/var/log/gatejs",
http: {
generalInterface: {
type: 'reverse',
port: 80,
},
},
})};
As in forward proxy mode, gate.js HTTP engine can run multiple network instances in http object. Each instance has it owns name defined as a Javascript object key, which is generalInterface in our example.
Below options for HTTP reversing
http: {
generalInterface: {
type: 'reverse',
address: "0.0.0.0",
port: 80,
/* SSL part */
ssl: false,
isTproxy: false
},
},
- type is the type of http interface, in our case you must define reverse.
- address is the service listening address, default 0.0.0.0
- port is the service port, default 80
- isTproxy activates response IP spoofing using TPROXY, default OFF (false)
Each website has it owns configuration where different parameters can be used such as proxyStream or locations. It also has a dedicated pipeline used to control the website flow.
A website configuration is stored using confDir + /reverseSites/someconfig.js for example: /etc/gatejs/reverseSites/someconfig.js
{
name: 'gatejs.org',
serverName: [ "*.gatejs.org" ],
interfaces: [ 'reverseInterface'],
proxyStream: {
nodeOne: {
type: "rr",
hybrid: true,
primary: [
{
host: "192.168.0.1",
weight: 10
},
{
host: "192.168.0.2",
localAddress: "192.168.1.2",
weight: 10
},
],
secondary: [
{
host: "192.168.1.1",
weight: 1
}
]
}
},
locations: [
{
name: 'root',
regex: /.*/,
pipeline: [
['proxyPass', "nodeOne"],
]
}
],
}
- name : name of the configuration used to create a context for the website, default is default. Logging used this name to split log files.
- serverName : hostnames associated with the website, this field isn't a regex but a gatejs nreg which work faster than regex for host header association but it supports only wildcard (*). With Gatejs nreg you can defined multiple millions of websites w/o overhead.
- interfaces : associate the website with an interface, if no interface specified then website is global
- proxyStream : defines output stream contexts, explained below
- locations : defines the association between a pipeline & proxyStream with an URL request
- host : IP address of the source server
- port : TCP port of the source server, default to 80
- weight : The proxy node weight used in load sharing, default to 1.
- localAddress : Specify the IP to bind for network connections. NOTE: In the case of network interface alias don't forget to use a /32 mask
- https : true to force using HTTPS, default false (off)
- timeout : connection timeout (in second) default 10 seconds
- retry : amount of retry after considering source server as down
- readTimeout : read timeout for source server in second, default 900 seconds w/o data -NYI-