This repository has been archived by the owner on Jun 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathone-host-rewrites.js
76 lines (69 loc) · 1.59 KB
/
one-host-rewrites.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* This is an example configuration for a reverse proxy which listens
* upon:
*
* 192.168.1.100:80
*
* Each incoming request for the virtual host "example.com" is
* forwarded to the local IP address & port pair:
*
* 127.0.0.1:8080
*
* Any request for "www.example.com" will also be forwarded, after
* rewriting.
*
* Usage:
* -----
*
* To use this configuration file please run:
*
* ./node-reverse-proxy.js --config ./examples/one-host-rewrites.js
*
*/
exports.options = {
/**
* The virtual host we're responding to.
*/
'example.com': {
/**
* The host and port to which we forward the requests.
*/
'host': '127.0.0.1',
'port': '8080'
},
/**
* The virtual host we're responding to.
*/
'www.example.com': {
/**
* Notice we don't define any 'host' and 'port' here, as we're
* merely redirecting visitors to example.com.
*/
/**
* Here we rewrite http://www.example.com/foo to
* http://example.com/foo
*/
rules: {
'^/(.*)': 'http://example.com/$1'
},
/**
* If we didn't care what path was requested, and just wanted
* to redirect a user to the root of the other site we could
* use this:
*
* rules: {
* '^/': 'http://example.com/'
* },
*
*
*/
},
};
/**
* The port we listen upon.
*/
exports.port = 80;
/**
* The addresses we will listen upon.
*/
exports.bind = new Array("192.168.1.100", "127.0.0.1");