So, my question is: Can I somehow combine this code, either through Ajax, or javascript or do it entirely in PHP (preferable) or if necessary to do it entirely in JS? I would ultimately like to be able to open a new window to a specified URL through a specified proxy. Using a proxy IP addresses allows you to mask or hide your own IP address. To debug network connection issues. Using a proxy with PHP’s cURL functions: To authenticate with a proxy via cURL and send a HTTP GET request follow along code given below and read the instructions specified as comments.
Hello again, my DynamoGeek friends!
I'm going to forego most of the time consuming fancy words today and just dump some (hopefully) useful information.
I had need to access a website via cURL through a VPN using PHP. Though my specific current VPN of choice is NordVPN, theoretically this information could be applied to any SOCKS based VPN service that requires authentication.
To help out those in the back of the room, and the search engines, I'll summarize what I did more concisely. I wrote some spiffy PHP code that proxies requests for webpages through NordVPN using cURL.
Php Curl Proxy
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_PROXY, 'us1111.nordvpn.com'); // Any SOCKS capable proxy URL
- curl_setopt($ch,CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); // Sets the proxy type for the connection to SOCKS
- curl_setopt($ch,CURLOPT_PROXYPORT,'1080'); // The port that NordVPN uses for all SOCKS connections
- curl_setopt($ch, CURLOPT_HEADER, FALSE); // Prevents the header from being included in the results
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); // Allows the connection to be redirected
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Causes the response to be returned as a string
- curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'Username:Password'); // Don't put your creds directly in the code
- curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); // Sets the authentication type for proxy connections
- curl_setopt($ch, CURLOPT_URL, $url); // I refuse to explain this option
- $results = curl_exec($ch); // The results of the request will end up in $results
I hope you've found this quick bit of information useful, and I'll see you next time.
Url Proxy Server
- Navigation
- Blog
- Options
- Current Location