Install Shadowsocks
- Download the latest version from Shadowsocks GitHub.
- Install it via the provided CLI commands.
Configure Shadowsocks
- Open
Shadowsocks / config / config.xmland edit the configuration. Include settings likeproxy_server,proxy_port, andproxy_name.
Set Up the Proxy
- Create a
proxy_config.xmlfile in your project's build directory. - Add the following:
<proxy_config> <proxy> <proxy_server>your_proxy_address:your_proxy_port</proxy_server> <proxy_port>88</proxy_port> <proxy_name>Shadowsocks Proxy</proxy_name> <proxy_user>username</proxy_user> <proxy_pass>password</proxy_pass> <proxy secure></proxy Secure> <proxy_catch errors></proxy_catch errors> <proxy_catch exceptions></proxy_catch exceptions> <proxy_catch timeout></proxy_catch timeout> </proxy> </proxy_config> - Generate
proxy.xmlandproxy.confif necessary.
Set Up PHP Project
- Configure your PHP project to use the proxy:
- Set
PHP_CORSIBLE_URLStotrueandPHP_CORSIBLE_PORTto88. - Enable HTTP and HTTPS proxying in your PHP configuration:
useHC \Proxies::proxy; useHC \Proxies::proxy_crf; useHC \Proxies::proxy_user; useHC \Proxies::proxy_pass; useHC \Proxies::proxy_catch; useHC \Proxies::proxy_catch_errors; useHC \Proxies::proxy_catch_exception;
- Replace all localhost URLs with your proxy URL:
$proxy_url = 'http://yourproxy_address:88/some_path';
- Set
Test the Proxy
- Use
curlto test the proxy:curl -d '{"host":"yourproxy_address:88", "port":88} http://example.com - Check the response headers for proxy information.
Deploy the Proxy
- Set up a web server (Nginx, curl, etc.) in your project's build directory.
- Configure the proxy in the server's
server.conf:Nginx::server
- Configure the proxy in the server's
proxy.conf:<proxy> <proxy_user>username</proxy_user> <proxy_pass>password</proxy_pass> <proxy_catch errors></proxy_catch errors> <proxy_catch exceptions></proxy_catch exceptions> <proxy_catch timeout></proxy_catch timeout> </proxy>
- Run the server:
curl http://localhost curl https://localhost
Test Deployment
- Access your proxy normally. If you're accessing from your own IP, it should block and redirect to an internal proxy.
Security Considerations
- Enable CAP-TLS for SSL/TLS.
- Configure CORS settings to prevent access from your own network.
Troubleshooting
- Use
curl -vto see the proxy response. - Check Nginx logs for proxy errors.
Considerations
- Shadowsocks is straightforward for beginners but may require more configuration.
- Compare Shadowsocks with Nginx for performance and ease.
By following these steps, you should successfully set up a Shadowsocks proxy for your PHP project, enabling remote access while maintaining security.
