Can't connect to a port but 80 in php - php

I have a webspace on a free hosting platform. The latter doesn't allow server-to-server connections to a port different from 80 in php scripts. I need to connect to another website on a port different from 80 using php Curl libraries, but obviusly it doesn't work, my host blocks the connection. Is there a method to bypass this limitation?

Sounds like it's a firewall limitation and you can only ask your hosting company for specific permission.
But if you have control over another website, you can send request to it's 80 and route to port xx.

Related

How to setup and run a PHP WebSocket service on a cpanel-based shared hosting platform?

I have created a Chat application in Ratchet PHP. It runs fine on local machine using WAMP. I want it to setup on live server.
On my server I have:
PHP Support
SSH access
Port 9000, which is opened for OutBound connections.
Sub-domains
What I don't have:
No port for InBound connections.
No root access in SSH. Say I cannot see/edit iptables
I ran php server.php which gives success message about the server is started and listening at port 9000. But when a HTML page tries to connect it using ws://domain:9000 it runs into error-
Firefox can’t establish a connection to the server at
ws://domain.com:9000/
I googled a lot and it appears that what I need is a port for inbound connections.
But according to this answer the thing I need is PHP support for Ratchet to work on shared hostings. Can anyone explains what I really need and Is there any workaround If it's not availble in the list of things I have on my server.
Basically, No
It is not likely for a shared hosting environment (i.e. Apache with VirtualHost config, PHP, MySQL, and a CPanel interface) to support your websocket application.
For websocket to work, you need to either:
have a port dedicated to websocket in-bound connections; or
have a HTTP/HTTPS server that knows when to upgrade a connection and proxy pass to your websocket application.
The first route requires the server to allow in-bound connection to a certain port number. This is a potential security issue for the hosting provider and, thus, is unlikely for your vendor to grant you that.
The second route requires Apache server have with both mod_proxy and mod_proxy_wstunnel installed and enabled. It also require you to use ProxyPass config, which cannot be overridden by .htaccess configs at all.
So unless your hosting grants you the permission to touch the Apache main configuration (or would apply such change for you), you're pretty hopeless.
Suggestion
To run your own websocket service, you should think about using Virtual Private Server services such as Amazon EC2, DigitalOcean VPS.

Access WAMP, different internet connections

I want a certain person to access my PHP program (connected to a MySQL database) but we live in different places. Is it possible for her to access my Wamp Server if we are connected to different internet connections? I got it to work with someone but we were connected to the same WiFi.
You need at least one connection between both LAN network either LAN or WAN.
You need to edit apache config file vhost access permission to "Allow from All".
Once you do that go to server's network router and forward all port 80,443 and 3306 traffic to wamp server's IP address it.
Now you can access wamp server directly by using WAN IP of server's network.
You'd basically have two options to make it visible to her:
Make your web server visible from the Internet which has lots of
security implications and might require you to use a custom port
since most ISPs block incoming requests on port 80. You would have to set up port forwarding in your router to point to your web server.
Set up a VPN server that she could connect to, which would also need to be port forwarded in your router. This also has security implications but would likely result in much fewer attacks.

how to host a website using xampp server?

I have created a website for sending emails, it works fine in localhost and in LAN connection, but I'm not able to open my website from another network.
I use my public IP address (found on whatsmyip.org), I have also forwarded port (80) to the server computer in my router settings page.
I'm using xampp version 5.6.3. please help me out with this.
Thanks in advance
Make sure your firewall allows incoming connections from port 80. To do this, open your computers firewall-configuration and create an incoming-rule for port 80. If you are using Windows 8 please refer to this Microsoft-help-page.
To view your website from the internet, these conditions must be met:
Make sure you use the correct ip
Have an ISP that allows trafic on port 80 (thanks to DarkBee)
Forward the port to the correct computer, using the nat of your router
Configure your firewall to accept connections from port 80
Make sure your xampp listens to all ip-adresses (see "Listen 80" in httpd.conf)

How can I bring my server online?

I don't think if it's possible, but I would like to bring my server temporarily online.
The thing is, I have been working on a PHP project lately from my home computer, and I need to show the progress to my follow team mates on their PC. Unfortunately I cannot go to them, but I wish if my website could.
We don't have a registered domain for it yet.
It's an APACHE v2.0 server installed, running PHP 5 and MySQL at the same time.
Is there some way I could possibly do that.
I heard some where that it's possible with Forwarding ports on DNS using static IP address or something like that. I am using Internet Connection using a HUWAEI Data Card Modem Model: E1550. Unfortunately, I cannot forward ports wit hit.
Any possibility I could share the website temporarily?
Why not just open up a free hosting account on a real good free host service like 000webhost, export your local database, upload your site to the remote host using ftp, then import your databases export file into the remote host's mysql and share the link to your site with your buddies?
That's what I do.
Install and set up Apache properly
Forward port 80 (or other, if you want) to your local IP, through your gateway settings
Register with your IP on DynDns.org or no-ip.org or something like that.
Edit: Well, you said "temporarily", you can just forward port 80 to your local IP and be happy with your "http://xxx.xxx.xxx.xxx/" but beware that it will change whenever you restart the router, or reestablish the connection.
What #MarkoD said, but until then -
If you have access to your router's firmware, you forward ports from there, not your actual PC. Just forward the port Apache is listening on, then put WAMP/XAMPP online.
Once it's online, share your IP and the port you chose with your team mates and they should be able to connect.
The link should look something like: http://111.111.111.111:2222.
For example, Cox Communications doesn't allow outgoing data on port 80 or 443, so use 8080
http://111.111.111.111:8080
If your ISP does, then just use 80 and drop the :xxxx.

Do we need a static IP to use HTML5 Websockets?

I am in the process of building a chat application in PHP using Web Sockets. I started with the code phpwebsocket project and here. The code works fine on my local machine but when i try it on my site (does not have a dedicated IP) it has a problem establishing the web socket connection. I tried it with all possible combinations for socket binding (site addres, external ip addr, local ip addr) but failed.
You must be able to connect to the port on the server where the WebSocket server is running. If you are using a port other than 80 or 443 on your site for the WebSocket server, then you probably need to configure (or ask) the site to accept incoming connections on that port (because they may deny it by default for security reasons). It you are unable to telnet to the WebSocket port on the server, then this is likely the case (or phpwebsocket is not in fact correctly configured to list on that port).

Categories