How does one Configure a Fixie Proxy on a Heroku Laravel App? - php

I'm trying to setup the Fixie Static IP Heroku Add-On for my Laravel Application.
Here's the only code that they supply in the documentation for PHP projects.
<?php
function proxyRequest() {
$fixieUrl = getenv("FIXIE_URL");
$parsedFixieUrl = parse_url($fixieUrl);
$proxy = $parsedFixieUrl['host'].":".$parsedFixieUrl['port'];
$proxyAuth = $parsedFixieUrl['user'].":".$parsedFixieUrl['pass'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyAuth);
curl_close($ch);
}
$response = proxyRequest();
print_r($response);
?>
My issue is that I don't know where this code should be placed within my Laravel App.
Should I be using Laravel Trusted Proxies? Or just configuring this manually?
I'm also using Custom Domains on Heroku, so when someone accesses the custom domain, I need the request to route through the Fixie Proxy and utilize the Static IP's.
Any help would be greatly appreciated.
I've tried searching around my codebase for where this code should be placed, but I'm not having any luck finding the solution.
There is another Add-On called QuotaGuard that does the same thing, and the documentation is almost identical.
I went with Fixie because there's a free plan, and I'm just trying to get the Proxy set up.
Thank you for any help in advance.

Related

CURL localhost via online server

I have a local website setup via MAMP at: http://127.0.0.1/wordpress/
Is it possible to CURL this local site via my online site? For example, in https://example.com/file.php, I test:
$url ='http://127.0.0.1/wordpress/';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
$content = curl_exec($curl);
curl_close($curl);
print_r($content);
But it doesn't work. Is it even possible for the client (website visitor) to access their localhost like this?
There are couple of good free service that let you do the same. Ideal for showing something quickly for testing purpose :-
http://localtunnel.me/
https://ngrok.com/
http://localhost.run/
You can use tool like ngrok for get a live url for your local projects. Please keep in mind that you cannot use ngrok like continues service. its just for quickie local to live platform for like testing purpose
Download ngrok from here , place the downloaded file in your project folder and simply run ./ngrok http 80
( here 80 is the port assuming your project running. it is subject to change as per your required)

API not work on Third Level Domain

i have some problems.
I need to keep data from coinmarketcap. When I was developing on localhost it worked well.
But on third level domain coinfollow.altervista.org i can not receive the data
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.coinmarketcap.com/v1/ticker/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($ch);
curl_close($ch);
$outputdecoded = json_decode($output, true);
echo $outputdecoded;
I try in another domain mywebsite.com and it worked. I think that the problem is coinfollow.altervista.org domain.
I need to save coinmarketcap data into my database with a simple query.
Does anyone know a solution?
It sounds like there is a server config issue on coinfollow.altervista.org, such as curl not being enabled for php.
You can run phpinfo(); to see if curl is installed.
If it is installed try running echo curl_error($ch) to see if there are any errors returning from curl

get response from remote server using ip board

i want to get data from remote API with curl but not works:
(im using ip board btw)
$url = "http://www.voobly.com/api/findusers/". $nick_list . "?key=" . $voobly_key;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
this is the response i get:
Please enable cookies. One more step
Please complete the security check to access www.voobly.com
Why do I have to complete a CAPTCHA?
Completing the CAPTCHA proves you are a human and gives you temporary
access to the web property.
What can I do to prevent this in the future?
If you are on a personal connection, like at home, you can run an
anti-virus scan on your device to make sure it is not infected with
malware.
If you are at an office or shared network, you can ask the network
administrator to run a scan across the network looking for
misconfigured or infected devices.
Cloudflare Ray ID: 3b009b3171e55c09 • Your IP: 69.89.31.238 •
Performance & security by Cloudflare
anyone know how to solve this
API provider said i need to add a valid browser agent string + PHP cookie session but idk what wrong here :(
The web site you're trying to access has misconfigured Cloudflare to block bots from accessing their site… including the API.
You will need to contact them to have them disable this. There is no easy workaround -- the whole point of this feature is to prevent scripts from accessing the site.

Steam as OpenID stopped working when I changed server

I did a website which uses Steam as OpenID provider. I firstly hosted it on a shared hosting.
But the traffic grew from 50 users in a day to 1000 in a day. I wasn't expecting that and had to change my host. I took another shared hosting with better performance, etc. to see how it is going to grow. But there's now a problem.
My OpenID login with Steam which worked perfectly on the last host doesn't work anymore. I tried with Google, and it worked. So I don't think my script uses a functionality that isn't enabled on my new host.
So when I put Steam identity, it loads during about 30 seconds and then Chrome returns me an error, ERR_EMPTY_RESPONSE. I tried to activate error_reporting E_ALL, but it does the same.
I am using LightOpenID, and here is the portion of the code incriminated:
$openid->identity = 'http://steamcommunity.com/openid';
header('Location: ' . $openid->authUrl());
Actually, it doesn't work whenever I call $openid->authUrl(). Here is the complete code: http://pastebin.com/rChDzECq
How can I resolve this? Thank you in advance.
I also had problems fighting the LightOpenID code in the last couple of hours. I finally made it work and here is what I learned in the process.
Absolutely no HTML output before the header() command. Even the tiniest space prevented the command from redirecting anything.
My server wouldn't allow the use of file_get_contents() and just returned a 404 error from the URL passed to it. You can solve this problem with a custom file_get_contents_curl() command. Here's the one I used myself:
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
I know this is a late answer but I hope it will help someone.

cURL can't connect in a free host but works fine in my localhost

I created a small web app, with the feature of being able to Sign in with a Twitter account, by connecting with OAuth. It worked like charm for a few months, but now it stopped working. This is a quick and summarized overview "Sign in with twitter" algorithm.
Collecting some parameters (timestamp, nonce, some kind of application ID and so)
Use this parameters to create a new URL that looks like this:
https://api.twitter.com/oauth/request_token?oauth_consumer_key=DLZZTIxpY19FnWJNtqw5A&oauth_nonce=1369452195&oauth_signature=DIetumiKqJu66XXVvDDHdepnP9M%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1369452195&oauth_version=1.0
Connect to that URL and retrieve the data, it has an access token
Continue doing fun stuff using that access token.
The URL generated in step 2 is fine because I tried manually copying it in Google Chrome, and it shows a beautiful access token, so the problem isn't there (I think).
In the step 3, I have a really small method that should do some very basic stuff: Connect to the URL generated before, retrieve the content and return it.
In my localhost Using EasyPHP 12.1, it works perfectly, as usual, but in the free host that i'm using (000webhost) it doesn't work anymore. When trying to connect, it just timeouts. The HTTPCodeError is 0 and the CurlError is "Couldn't connect to host".
This is the method used to connect to the URL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
And this is an example of a URL used with that method:
https://api.twitter.com/oauth/request_token?oauth_consumer_key=DLZZTIxpY19FnWJNtqw5A&oauth_nonce=1369452195&oauth_signature=DIetumiKqJu66XXVvDDHdepnP9M%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1369452195&oauth_version=1.0
I've been trying to fix it all day long, but now I have no idea even of what to try. The files are the very same in my localhost and in the 000webhost.
If you could enlighten me I would be very happy. I'll take my pants off for answers if it's needed. Thank you very much.
It might be possible that Twitter has blacklisted (blocked) your free host's servers or IP address. This can happen if other users on the server abuse the API.
The only thing I can think of is that your free web hosting service blocks it. You know these services are perfect as long as everything is very simple. The moment things become complicated you run into restrictions implemented by the provider. Most of these services limit band width, disk space, server use, support, uploading and more.

Categories