HTTP_Request2 GET error - php

I am trying to connect to my Amazon EC2 website from my PHP server hosted on Godaddy. So using HTTP_Request2, I use the following:
$request = new HTTP_Request2('http://XX.XX.XXX.XXX:3007/something/something', HTTP_Request2::METHOD_GET);
This returns the following:
Error: Unable to connect to tcp://XX.XX.XXX.XXX:3007. Error: Connection refused
Now I know the port on my Amazon server is open and works when using jQuery to connect to it from my own machine or even my Godaddy website. However when trying to do the same thing except with PHP, it isn't working. I have made sure that I have installed request2 package on my Godaddy server.

Found out the problem. The problem is GoDaddy doesn't allow using custom ports (such as 3007 port I was trying to use) with curl or request2. A workaround to use on another server you are trying to connect to (if you manage/own that server):
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
was posted at https://stackoverflow.com/a/16573737/4553140

Related

Centralised Mysql DB

I need solution for Centralized DB.
We have DB in one Hosting server (Azure Redhat virtual server) and we need to use the same db in other hosting server too. So it will be centralized DB for both server. I can not use it in navicat also if I use IP of Mysql DB.
I have tried using ( bind-address= IP address of the server where db is hosted ) in My.cnf file but it doesn't allow remote access. to use it in other hosting server nor in any mysql client like navicat / Heidi sql.
Also I have added the port 3306 rule in azure server for inbound security.
Thanks in advance for help.
As Azure VMs disable ICMP and we can use SSH tunnels to allow outside access to internal network resources.
Please try to follow this post, created a SSH tunnel in VM which hosted the MySQL server:
Open port 3306, so a remote client can connect to your MySQL Server. Run the following command to open TCP port 3306
iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
Now let’s check if the port 3306 is open by running this command:
sudo netstat -anltp|grep :3306
Create a SSH tunnel for port 3307
sudo ssh -fNg -L 3307:127.0.0.1:3306 azurevmuser#servername
Create an endpoint for the port 3307 rule in azure server for inbound security. Now your Database host name is <VM_ip>:3307
Any further concern, please feel free to let me know.

Redis-php not working from web browser

I have installed redis packages on my AWS ubuntu server and everything is working fine from the command line.
I have run the below things from command line and it shows me correct response.
netstat -nlpt | grep 6379
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 23504/redis-server
so my redis server is running correctly on 6379 port also I have added this port on aws security group so firewall is also not blocking.
Also when I check my redis log it also seems to be fine. below is my log.
The server is now ready to accept connections on port 6379
But when I run the below code from my PHP and I get the below error.
$redis = new Redis();
$redis->connect('localhost');
$redis->set('param',999);
echo $redis->get('param');die;
Error I am getting...
The mcook.co.in page isn’t working
mcook.co.in is currently unable to handle this request.
HTTP ERROR 500
I have tried the below solution mentioned in stackoverflow.com but none of are working for me.
Redis - Connect to Remote Server.

How to enable PHP's built-in web server on wercker

I have setup my wercker.yml file with the following step midway:
- script:
name: Serve application
code: php -S localhost:8000 >> /dev/null &
That appears to run, however, in another step when I try cURL to http://localhost:8000 I get the following:
curl: (7) Failed to connect to localhost port 8000: Connection refused
It does it for all ports, not just 8000. Has anyone else managed to get PHP's in built server working in wercker, or open any ports?
Assuming you're using the wercker CLI and trying to set up a development pipeline, you need to use wercker dev with the --publish 8000 argument. This will forward the traffic from your host on port 8000 to the container on port 8000.
Also, if you're using boot2docker, you can't specify localhost, since boot2docker spins up a VM that runs docker. In that case you'll need to use your boot2docker IP, which you can find by running the boot2docker ip command.

Can't connect Websocket when using vagrant envirionment

I'm using Vagrant box using puphpet, the environment is PHP 5.5 + ubuntu 12.04 + apache + mysql. My Vagrant VM ip: 192.168.11.11, local machine hosts points to 192.168.11.11 reactphp.dev, and it works.
And, I'm using this code: https://github.com/muuknl/phprealtimechat to test websocket.
Then I visit reactphp.dev in my Chrome browser, and I start server script using: php bin/server.php, and after I type in the username I just got the error:
WebSocket connection to 'ws://192.168.11.11:2000/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
It works well when I changed the websocket ip to `ws://127.0.0.1:2000/', but why it does not work if I change to my VM's ip address?
It's been a while I haven't used PuPHPet, but when I had troubles connecting through the port (minus port 22), I've had to issue the command sudo ufw disable in the vagrant machine.
If uwf isn't the managing firewall of your vm, try sudo service iptables stop, or sudo iptables -F.
Perhaps they've changed the behavior since then, but it's still good to try.
The SSH tunnel (over the opened port 22) might allow you to access the local port 2000, which is proxified over. The actual port 2000 of the VM might be limited due to firewall.
Try it, and tell me if this works. If not, I'll dig in deeper.

cURL couldn't connect to host, but it connects to my domain address

I am new to Linux. I had the php project in the Linux server. I am using the cURL command in my php page to access Google, but it says it couldn't access the host.
From the command line, I can ping the Google site, while cURL and Wget commands fail.
I had checked the firewall: selinux=disabled and selinuxtype=targeted.
Try this command from a terminal
telnet www.google.com 80
Do you get any output? Like Connected to www.google.com? If not, then the outgoing access to google.com on port 80 is blocked.
Ping uses the ICMP protocol. cURL (and telnet) uses TCP on port 80 or 443.

Categories