You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/recipes/global-proxy.md
+51-11
Original file line number
Diff line number
Diff line change
@@ -32,34 +32,74 @@ this.proxy = {
32
32
};
33
33
```
34
34
35
-
### Include
35
+
### Target-Specific Proxy Configuration
36
36
37
-
You can limit the proxy to specific hosts by defining a list (or array) of hosts it should be used for:
37
+
Lucee provides two mutually exclusive methods to control which hosts use the proxy: **includes** and **excludes**. These options allow you to fine-tune proxy usage based on your application's requirements.
38
+
39
+
> **Important**: The `includes` and `excludes` options only support exact hostname matches. Wildcards and partial matches are not supported. All hostnames are converted to lowercase for comparison.
40
+
41
+
#### Using `includes`
42
+
43
+
The `includes` option specifies a whitelist of hosts that should use the proxy. Any request to a host not in this list will bypass the proxy and connect directly. This is useful when you only need to access specific external services through a proxy.
44
+
45
+
```lucee
46
+
this.proxy = {
47
+
server: "myproxy.com",
48
+
port: 1234,
49
+
username: "susi",
50
+
password: "sorglos",
51
+
includes: "api.example.com,cdn.example.com"
52
+
};
53
+
```
54
+
55
+
You can also use an array instead of a comma-delimited list:
38
56
39
57
```lucee
40
58
this.proxy = {
41
59
server: "myproxy.com",
42
60
port: 1234,
43
61
username: "susi",
44
62
password: "sorglos",
45
-
includes: "whatever.com,lucee.org"
63
+
includes: ["api.example.com", "cdn.example.com"]
46
64
};
47
65
```
48
66
49
-
###Exclude
67
+
#### Using `excludes`
50
68
51
-
Or you can do the opposite, defining for which hosts it should not apply:
69
+
The `excludes` option specifies hosts that should bypass the proxy. All other hosts will use the proxy. This is useful when most of your traffic should go through the proxy, but certain hosts should connect directly.
52
70
53
71
```lucee
54
72
this.proxy = {
55
73
server: "myproxy.com",
56
74
port: 1234,
57
75
username: "susi",
58
76
password: "sorglos",
59
-
excludes: ["lucee.org", "whatever.com"]
77
+
excludes: "internal.example.com,localhost"
60
78
};
61
79
```
62
80
81
+
You can also use an array instead of a comma-delimited list:
82
+
83
+
```lucee
84
+
this.proxy = {
85
+
server: "myproxy.com",
86
+
port: 1234,
87
+
username: "susi",
88
+
password: "sorglos",
89
+
excludes: ["internal.example.com", "localhost"]
90
+
};
91
+
```
92
+
93
+
#### Special Handling for Local Addresses
94
+
95
+
By default, local addresses (`localhost`, `127.0.0.1`, and `0:0:0:0:0:0:0:1`) are automatically excluded from proxy usage unless explicitly included in the `includes` list. This is a built-in behavior to prevent proxy loops and ensure local connections remain direct.
96
+
97
+
#### Restrictions
98
+
99
+
- You cannot use both `includes` and `excludes` in the same proxy configuration. You must choose one approach.
100
+
- If you specify an empty list for either `includes` or `excludes`, it will be treated as if the option was not provided.
101
+
- All hostname comparisons are case-insensitive.
102
+
63
103
## Configuring Proxy in .CFConfig.json
64
104
65
105
In addition to Application.cfc, you can also configure the global proxy in a .CFConfig.json file:
@@ -72,8 +112,8 @@ In addition to Application.cfc, you can also configure the global proxy in a .CF
72
112
"port": 1234,
73
113
"username": "susi",
74
114
"password": "sorglos",
75
-
"includes": "good.org",
76
-
"excludes": "bad.com,whatever.com"
115
+
"includes": "api.example.com,cdn.example.com",
116
+
"excludes": null
77
117
}
78
118
}
79
119
```
@@ -87,7 +127,7 @@ Both methods support the following configuration options:
87
127
-**port** - The port number of the proxy server
88
128
-**username** - Optional username for proxy authentication
89
129
-**password** - Optional password for proxy authentication
90
-
-**includes** - Comma-delimited list or array of hosts that should use the proxy
91
-
-**excludes** - Comma-delimited list or array of hosts that should not use the proxy
130
+
-**includes** - Comma-delimited list or array of hosts that should use the proxy (exact match only)
131
+
-**excludes** - Comma-delimited list or array of hosts that should not use the proxy (exact match only)
92
132
93
-
Note that you cannot use both `includes` and `excludes` at the same time - you must choose one approach.
133
+
Remember that you cannot use both `includes` and `excludes` at the same time - you must choose one approach. If both are provided, the behavior is undefined and may change in future versions.
0 commit comments