Open a page available only on the server (backend proxy) - php

I have a frontend application that need to call a reporting services, opening a new window with a javascript function like this :
window.open('http://somedomain.com:8080/report')
What I wanna do now is, since the tomcat server is on the same machine of the backend application(and on the same machine of the web server - php), avoid to open the 8080 port on the internet.
In simple words, I need a way to connect the tomcat application server(through localhost) and proxy the connection to the frontend without requiring to open the port 8080 of the server to the all world. Is it possible ?
How can it be done ?
To generate html page on the server I use php...
EDIT/UPDATE
The page on the tomcat application server is not static, it has a loading mechanism and need user interaction ...

You could use PHP's cURL functions to get the information you need via PHP (using localhost:8080) and use this as a PHP proxy. Then use Ajax to retrieve the information from the PHP proxy.

Related

Load a page server-side and deliver to web browser

I'm working on a raspberry pi project where i've set up a media centre with an apache web-interface over my LAN. I've recently installed the deluge-web browser GUI for managing torrents which runs over a different port.
I'm forwarding port 80 so that I can access the media center interface when i'm away from home for management, but would like to get it set up so i can access the deluge-web ui without having to forward its port, so that i can implement a stricter security control using mysql or php with apache.
So what i'm trying to do is set up a frame which is loading the deluge-web ui on the server-side, visible and accessible by the browser.
I'm running apache 2.2.22, php 5.4.39, raspian (debian 7.8).
Is that it all possible?
No. A frame is a client side technology. It can't do anything about permissions or creating network paths to internal servers.
If you want to make a service accessible with added authentication, then you'll need to look at using something like an SSH tunnel or HTTP proxy instead.
If I understand right, what youre looking for is curl. Check Curl Documentation on PHP Site. Basically, it can download any url (page/file/whatever) and then you can use it in your php script, possibly dumping it into an iframe or div.

HTTP_Request call works in browser, timeout in web app

I have a web application which gets data from itself via a REST API in JSON format. I am in the process of moving this site to a new server on a new host. I have everything moved, same database, same files. The main differences would be that PHP is running as a module on the new server instead of FastCGI and the new host has a client-configurable-firewall.
The web app makes the API call by using Pear's HTTP_Request object (GET method). When I run the web app that makes the call, it spins until it finally returns a "Connection timed out" error.
However, if I echo the URL being used by the call and then hit that directly in my browser it returns all the JSON data instantly.
I am wondering if this could be a firewall issue: port or protocol used by the guts of Pear's HTTP_Request object blocked? (There is currently a firewall policy allowing traffic on port 80 from any IP).
Or a permission issue: PHP running as a module is more sensitive to this.
Any ideas would be greatly appreciated!
As the new server is still only being tested using the IP address, the internal web application was attempting to access itself via an external IP. From the server itself, the external IP is not available. It has to be changed to point to the internal network IP for testing.
Once the domain name is moved this will become a non-issue again.

How to Develop an Arbitrary Socket.IO Client that can Connect to a Socket.IO Server

I am trying to develop a socket.io application. It is just a simple application like the one on the Getting Started - Chat application tutorial in the Socket.IO webpage. But the problem is that, I do not want to have the socket.io server serve the client automatically, because I am planning to have a page (in PHP) have a script that can simultaneously be updated by data from a server in real-time using Socket.IO. I just want a certain client that can connect to the server and let them communicate, not a page served by the socket.io server.
Is this possible? Can you please give an idea on how can it be done. Thanks.
That chat tutorial is just a simple deployment where your own web page wants to connect back to the same server that the web page came from. That is not the only way to do it.
The socket.io client code can be served from anywhere. You can even link to a CDN and get it from there instead of from your own server.
And, likewise, the client can connect to any compatible server as long as the server is configured to accept a connection from your page.
If you're looking for how to connect to a different server, you just specify the URL of the desired host in io.connect() like this:
var socket = io.connect('http://www.example.com');

how to put php and node.js togther

I have test node.js + socket.io with port 8080 yesterday
i found that the frontend page which receive the data and send request must defined as HTML
which mean, i can use a mvc php combine with node.js and socket.io
is there any way to do that?
more if i define the node server as localhost:8080
i cant call the web server by other place, such as localhost
unlike nature websocket, i can use the socket anywhere, and i just need to define the socket address as localhost:8080
anyway to solve out?
Run node on port 8080 run php on port 8081. Use php to run your frontend HTML and JavaScript include the frontend socket.io library and connect to localhost:8080 (the node server)
// client side code
var socket = io.connect('http://localhost:8080');
This is untested, and I don't know if this is what you want, or if it will work.

Execute local application via PHP from server

My company has an internal Linux server running PHP with an application that displays client specific information, such as SSH connection info, etc. Is there a way to have the server invoke a command on a local machine via PHP? For example, the server displays a link with SSH connection information, such as c:\putty.exe -ssh someone#192.168.1.100 -pw MyPassword`. The user - on a windows machine - clicks the link and Putty fires up with all the connection information.
I believe Flash's fscommand has the capabilities I'm looking for, although I would much prefer to use PHP, if at all possible.
PHP is a server side technology and as such does not have any control over the client. You'll have to use a client side tech like flash or if it's IE only, ActiveX
Only way to things like this is mount your resource on server machine. To do that you have to have a server that will be visible for server and able to host your files.

Categories