Verify Apache availability behind Azure Balancer for each VM - php

Status:
2xA2 Azure VM with WAMP, behind Load Balancer
endpoint monitoring set
Question:
How do i check the Apache availability for each VM (as port 80 is now balanced and i cannot individually check a machine)?
I need to check the response via a php script to be able to automatically deploy further custom actions.
Is there a way to manually check (via php, or online service) a probe.html(or specific file for each machine) that reside on each machine, in any way?

If the two VMs exist on a private Azure VNET you could add a third machine to that VNET from which to perform the monitoring and then use the private IP address of each machine as your test endpoint.

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.

Connecting to Docker Container Network from the Client Side

I have two containers, a php server serving a laravel application and a spring boot application running a websocket server. My architecture was to connect the two containers using Docker Networking and have the Laravel container port published to the outside. The laravel application is pretty much all front end, and on one page is a chat room using websocket. I tried to connect the chat room to the Spring Boot websocket container name (Docker network) but I feel like because this request is coming from the client this is not possible? I am using the container name (domain name) as a URL on the javascript file that is being served by the php server. Would the only way to make this work is publish the Spring Boot port as well on a public server and replace the websocket url with a public url?
Additional info like docker-compose or commands you are running would also be helpful.
But from what I see, the issue probably is that the requests are coming from the client which means that they can't access the actual service since it's not available publicly...
You should probably make that service available as well by mapping the necessary ports to your host machine or create some proxy server to pass the requests to the websocket

Server data accessing from non local network without port forwarding

I'm using XAMPP server and I have my files in htdocs folder of XAMPP.
I had connected to my laptop using my mobile hotspot.
Can I access my files in XAMPP folder from another system which is not in same network i.e., can I access the files present in XAMPP folder from another another computer via internet
without router only by mobile hotspot?
Yes, it's possible to access the web server from an external network, depending on your current network configuration.
There are two simple solutions I think would suit you.
Configure your firewall if needed, enable port forwarding in your router settings to forward port 80 to the internal IP of the machine running your XAMPP-server.
If you're on a network in which you can't configure, I recommend checking out ngrok.com, which is a service where you can setup a public URL for your XAMPP-server. Works from any type of network, where you have internet-access, of course.
Note, alternative 2 is good for exposing a development-server, nothing I'd recommend for running a site in production.
Most network providers don't allow accessing the termials in the network.
If your provider does portforwarding and entering the public(!) IP of your hotspot should bei enough.

PHP - Amazon Elastic Beanstalk - Get private IP address

I am hosting a web app in Amazon Elastic Beanstalk (EB). The web app is written in php. EB also uses Elastic Load Balancer (ELB). The web app implements a websocket with the client.
Here is what I have done so far:
I know I have to listen to the private ip, not 127.0.0.1 of the instance for this to work
implemented a listener in load balancer to connect to the instance port
opened inbound and outbound traffic for the port in security groups.
If the EB deployment goes for horizontal scaling (increase the number of instances), will the private ips of the scaled instances remain same (please explain)? If not, and I believe so, how do I get the private ip address of the current instance that is serving the client?
So far its working perfectly without any problem, but there's only one instance running. I tried listing the clients and I can get the private ips with the list but I don't know how to identify the instance that is currently serving the file.
Please help me.
This will do the trick:
<?php $ip = shell_exec('hostname -i'); ?>
important: this works only for the linux environment. For windows, hostname -i is not valid. You can refer to https://superuser.com/questions/382265/ for further ideas.

EC2 (t1.micro) Windows XAMPP Can't Connect via web

I have opened a micro instance on AWS with a Windows_Server-2008-R2_SP1-English-64Bit-Base-2013.11.13 (ami-1e53c82e) virtual machine. RDS is open and I have connected with remote desktop connection. Additionally, at initialization I set HTTP (port 80), and HTTPS (port 443) although I do not know how to verify that now. From within the VM I navigated to XAMPP and installed a default installation (minus MySQL). I then navigated to XAMPP control panel V3.2.1 and started Apache. I set a password on XAMPP directory. I set a "Hello World" test txt file in htdoc and that loads in the VM browser. However, when I try to access the pubic IP, my local browser times out.
I think I covered the first three checks on
"xampp configuration in windows server 2008 r2 ec2 instance" post
but not sure how to change the elastic or private IP response if that is relevant.
If you're using VPC, you have to allow both inbound/outbound in the network ACL and inbound for the security group. You probably also have to open the ports in the windows firewall.
Edit: You definitely don't want to disable the firewall altogether. Also, it doesn't matter whether you use public ips from within AWS. And public host names resolve locally anyway.

Categories