Skip to content

Commit d8f969a

Browse files
committed
improve doc for global proxy
1 parent 6f71ba7 commit d8f969a

File tree

1 file changed

+51
-11
lines changed

1 file changed

+51
-11
lines changed

docs/recipes/global-proxy.md

+51-11
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,74 @@ this.proxy = {
3232
};
3333
```
3434

35-
### Include
35+
### Target-Specific Proxy Configuration
3636

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:
3856

3957
```lucee
4058
this.proxy = {
4159
server: "myproxy.com",
4260
port: 1234,
4361
username: "susi",
4462
password: "sorglos",
45-
includes: "whatever.com,lucee.org"
63+
includes: ["api.example.com", "cdn.example.com"]
4664
};
4765
```
4866

49-
### Exclude
67+
#### Using `excludes`
5068

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.
5270

5371
```lucee
5472
this.proxy = {
5573
server: "myproxy.com",
5674
port: 1234,
5775
username: "susi",
5876
password: "sorglos",
59-
excludes: ["lucee.org", "whatever.com"]
77+
excludes: "internal.example.com,localhost"
6078
};
6179
```
6280

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+
63103
## Configuring Proxy in .CFConfig.json
64104

65105
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
72112
"port": 1234,
73113
"username": "susi",
74114
"password": "sorglos",
75-
"includes": "good.org",
76-
"excludes": "bad.com,whatever.com"
115+
"includes": "api.example.com,cdn.example.com",
116+
"excludes": null
77117
}
78118
}
79119
```
@@ -87,7 +127,7 @@ Both methods support the following configuration options:
87127
- **port** - The port number of the proxy server
88128
- **username** - Optional username for proxy authentication
89129
- **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)
92132

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

Comments
 (0)