{"id":13518908,"url":"https://github.com/softius/php-cross-domain-proxy","last_synced_at":"2025-04-04T10:09:11.063Z","repository":{"id":3489343,"uuid":"4545337","full_name":"softius/php-cross-domain-proxy","owner":"softius","description":"PHP Proxy for Cross Domain Requests","archived":false,"fork":false,"pushed_at":"2022-06-10T23:06:10.000Z","size":42,"stargazers_count":272,"open_issues_count":17,"forks_count":143,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-12-26T09:31:19.636Z","etag":null,"topics":["enable-cors","php","php-cross-domain","php-proxy"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-04T09:19:00.000Z","updated_at":"2024-11-19T07:25:26.000Z","dependencies_parsed_at":"2022-08-06T14:01:01.976Z","dependency_job_id":null,"html_url":"https://github.com/softius/php-cross-domain-proxy","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softius%2Fphp-cross-domain-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softius%2Fphp-cross-domain-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softius%2Fphp-cross-domain-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softius%2Fphp-cross-domain-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softius","download_url":"https://codeload.github.com/softius/php-cross-domain-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157283,"owners_count":20893220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["enable-cors","php","php-cross-domain","php-proxy"],"created_at":"2024-08-01T05:01:50.661Z","updated_at":"2025-04-04T10:09:11.032Z","avatar_url":"https://github.com/softius.png","language":"PHP","readme":"# PHP CORS Proxy\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Total Downloads][ico-downloads]][link-downloads]\n\n*Formerly known as \"PHP Cross Domain (AJAX) Proxy\"*\n\nPHP CORS Proxy is a simple php script that allows cross domain requests. It can be used to access resources from third party websites when it's not possible to enable CORS on target website i.e. when you don't own that website.\n\n**Note**: Please check whether this solution is indeed necessary by having a look on [how you can enable CORS on your server](http://enable-cors.org/server.html).\n\n## Overview\n\n\n### Features\n\n* Acts as a reverse proxy: request headers and data are propagated from proxy to server. Similarly, response headers and data are propagated from proxy to client.\n* Provides support for all methods GET, POST, PUT, DELETE.\n* Provides also support for HTTPS.\n* Requests can be filtered against a list of trusted domains or URLs.\n* External configuration (Work in progress)\n* Error handling i.e. when server is not available (Work in progress)\n* Debugging mode (Work in progress)\n\n### Requirements\n\nPHP Cors Proxy works with PHP 5.3+ or above.\n\n### Author\n\n- [Iacovos Constantinou][link-author]  - softius@gmail.com - https://twitter.com/iacons\n- See also the list of [contributors][link-contributors] which participated in this project.\n\n\n### License\n\nPHP CORS Proxy is licensed under GPL-3.0. See `LICENCE.txt` file for further details.\n\n\n## Installation\n\n**Using composer**\n\n```\ncomposer require softius/cors-proxy\n```\n\n**Manual installation**\n\nThe proxy is indentionally limited to a single file. All you have to do is to place `proxy.php` under the public folder of your application. \n\n### Configuration\n\nFor security reasons don't forget to define all the trusted domains / URLs into top section of `proxy.php` file:\n\n``` JAVASCRIPT\n$valid_requests = array(\n    'http://www.domainA.com/',\n    'http://www.domainB.com/path-to-services/service-a'\n);\n```\n\n**Note**: There is currently ongoing work to allow configuration outside the `proxy.php` \n\n## Usage\nIt is possible to initiate a cross domain request either by providing the `X-Proxy-URL` header or by passing a special `GET` parameter. The former method is strongly suggested since it doesn't modify the request query. Also, the request looks more clear and easier to understand.\n\n### Using headers\n\nIt is possible to specify the target URL by using the `X-Proxy-URL` header, which might be easier to set with your JavaScript library. For example, if you wanted to automatically use the proxy for external URL targets, for GET and POST requests:\n\n``` JAVASCRIPT\n$.ajaxPrefilter(function(options, originalOptions, jqXHR) {\n    if (options.url.match(/^https?:/)) {\n        options.headers['X-Proxy-URL'] = options.url;\n        options.url = '/proxy.php';\n    }\n});\n```\n\nThe following example uses `curl`\n\n```\ncurl -v -H \"X-Proxy-URL: http://cross-domain.com\" http://yourdomain.com/proxy.php\n```\n\n\n### Using query\n\nIn order to make a cross domain request, just make a request to http://www.yourdomain.com/proxy.php and specify the target URL by using the `csurl` (GET) parameter. Obviously, you can add more parameters according to your needs; note that the rest of the parameters will be used in the cross domain request. For instance, if you are using jQuery:\n\n``` JAVASCRIPT\n$('#target').load(\n    'http://www.yourdomain.com/proxy.php', {\n        csurl: 'http://www.cross-domain.com/',\n        param1: value1,\n        param2: value2\n    }\n);\n```\n\nThe following example uses `curl`\n\n```\ncurl -v \"http://yourdomain.com/proxy.php?csurl=http://www.cross-domain.com/\u0026param1=value1\u0026param2=value2\"\n```\n\n[ico-version]: https://img.shields.io/packagist/v/softius/cors-proxy.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/softius/cors-proxy.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/softius/cors-proxy\n[link-downloads]: https://packagist.org/packages/softius/cors-proxy\n[link-author]: https://github.com/softius\n[link-contributors]: ../../contributors\n","funding_links":[],"categories":["PHP","\u003ca id=\"1a9934198e37d6d06b881705b863afc8\"\u003e\u003c/a\u003e通信\u0026\u0026代理\u0026\u0026反向代理\u0026\u0026隧道","\u003ca id=\"d03d494700077f6a65092985c06bf8e8\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"56acb7c49c828d4715dce57410d490d1\"\u003e\u003c/a\u003e未分类-Proxy","\u003ca id=\"0ff94312f3ab4898f5996725133ea9d1\"\u003e\u003c/a\u003e未分类"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftius%2Fphp-cross-domain-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftius%2Fphp-cross-domain-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftius%2Fphp-cross-domain-proxy/lists"}