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: README.md
+70-36Lines changed: 70 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,8 @@ This is such a script.
11
11
12
12
13
13
14
+
15
+
14
16
Installation
15
17
---
16
18
@@ -42,41 +44,9 @@ And then for example add a `proxy.php` like this to your web application:
42
44
43
45
```
44
46
45
-
Security
46
-
---
47
-
48
-
The whitelist array can contain any number of these criterias:
49
-
50
-
- Exact paths
51
-
`['http://example.com/api/specific-method']`
52
-
- Array with single regex key
53
-
`['regex' => '%^http://example.com/api/%']`
54
-
- Array with any [parse_url](http://php.net/manual/en/function.parse-url.php) components to match
55
-
`['host' => 'example.com']`
56
-
`['host' => 'example.com', 'scheme' => 'https']`
57
-
58
-
The requested URL must match at least one of the whitelisted criterias to be accepted, otherwise a 403 will be returned. An empty whitelist will accept any requests.
@@ -89,7 +59,10 @@ On the client-side, when performing cross-origin requests:
89
59
All parameters and HTTP headers (except `Cookie`, `Host` and `X-Proxy-URL`) will be used to recreate the request and performed server-side by the proxy. When complete it will mirror the response, including headers, and return it to the client-side script more or less as if it had been called directly.
When using `cache:false` jQuery adds a `_` GET parameter to the URL with the current timestamp to prevent the browser from returning a cached response. This happens *before* the `ajaxSend` event, so in the above case, if you had set `cache:false`, that `_` parameter would just be "moved" to the `X-Proxy-URL` header and no longer have any effect. So instead, leave `cache` at its default value `true`, and add the parameter manually to the proxy url instead.
142
128
143
-
**More?**
129
+
*Some more examples can be found in [test/index.html](test/index.html).*
130
+
131
+
132
+
133
+
Security
134
+
---
135
+
136
+
The hostname of the referer is checked, but can be easily spoofed, so the whitelist array should be put to good use. Fill it with any number of the following types of criterias:
137
+
138
+
- Exact paths
139
+
`['http://example.com/api/specific-method']`
140
+
- Array with single regex key
141
+
`['regex' => '%^http://example.com/api/%']`
142
+
- Array with any [parse_url](http://php.net/manual/en/function.parse-url.php) components to match
143
+
`['host' => 'example.com']`
144
+
`['host' => 'example.com', 'scheme' => 'https']`
145
+
146
+
The requested URL must match at least one of the whitelisted criterias to be accepted, otherwise a 403 will be returned. The whitelist can also be set to an empty array to allow any URLs.
Cookies sent to the proxy will be ignored, since the browser will send the ones meant for the domain of the proxy, and not the cookies meant for the proxied resource. Don't want stuff to leak!
175
+
176
+
If a request requires a certain cookie set, for example a session id, you can set the `X-Proxy-Cookie` header which is then used as `Cookie` header by the proxy.
0 commit comments