I have two EC2 servers. One runs Windows Server 2012 R2 and the other runs on Amazon's Linux build. The Linux box is used as a web server with PHP doing the scripting. I would like the Linux server to send a string to the Windows server every time a PHP file (acting as a RESTful end-point) is processed.
I've never done anything similar and was wondering where to start. From the research I've done so far, it seems like using Netcat to create a Telnet connection might do the job. If so, what would the boilerplate code look like? Netcat is a pretty old platform and there's not much to be found in terms of examples from a Google search.
I am also open to other solutions that could solve this problem.
The workflow of what I am trying to do looks like:
A user hits PHP file end-point -> PHP or the server it runs on sends a string to the Windows Server -> Windows server receives the string and starts a script
You could think of exposing this as an endpoint on your Windows server using either of:
IIS + PHP
IIS + CGi/Perl
IIS + Asp
or anything else.
Expose a simple page on IIS (Windows web server) and hit that from within your webservice login (Linux server) whenever the Linux server receives a request. The script/page that is exposed by your Windows server could execute the desired script then.
The page/endpoint that is exposed on the Windows server should be protected so that not anyone could execute it (disabling public ips. Restricting only the Linux server Ip in your firewall rules etc.)
Sample
Within your php webservice - $my_var = file_get_contents('http://WinServerPrivateIp/runScript.pl'); // Make it asynchronous if needed
runScript.pl in Windows - Would execute your actual script.
You could look at calling winexe from within PHP. I haven't done it myself but I've read that this should do the trick.
winexe Sourceforge
Some sample code from within PHP here
I hope that this is of some help to you
Regards
Liam
Related
In Qt webassembly documentation there is a mention, than one can use QNetworkAccessManager for HTTP communication with the server that hosts my website. The problem is, that I can't hard-code URL for the server as it should be able to be deployed on any server. Is there a simple way to receive it somehow?
The problem is, that I can't hard-code URL for the server as it should be able to be deployed on any server. Is there a simple way to receive it somehow?
Yes. Your server program runs a QApplication, and the single instance of that class could get that URL.
In other words, you'll document that your C++ program (the executable file obtained by compilation, e.g. with GCC) foo would accept some --server-url argument, and you would start foo --server-url http://example.com/somestrangeurl/
Please notice that WebAssembly is often running inside Web browsers (that is, inside Web or HTTP clients). Most HTTP servers (e.g. lighttpd) are running on Linux OS (and you might use Wt or libonion or some other HTTP server library for them, if you have to code your HTTP server from scratch).
I am trying to deploy a simple HTTP API app on an Window Server 2012 and it's not working. The app is accessible internally (I can ping it within the server) but NOT externally. What do I need to do make the API server accessible via network? I disabled the firewall so it's not a firewall issue. I would usually use Linux, but I don't have a choice but use Windows this case. Please help!
I solved it by installing IIS and use it as a reverse proxy. So when a http request comes in from the internet, IIS it takes it and forwards it to my web app.. I am not sure this is the right way or not, but if it is, then it's pretty stupid as my web app should be accessible directly which would have been the case if I were using Linux.
Im new in C++.
I need to listen HTTP requests.
Please advice me some good tutorials or examples
Thanks
update:
Platform: Windows
Language: C++
I will explain more clearly what i need
when user clicks row on this page: http://ucp-anticheat.org/monitor.html applications is automatically starts on client machine.
I want to make same thing.
I think on client side is service which listens http requests and if url starts with steam:// service automatically runs application...
Do i need to listen http requests?
What is best solution for my problem?
You can listen to http requests through a web server like mongoose , which can be easily used in C++ http://code.google.com/p/mongoose/ , and here is a good example of using mongoose web server http://code.google.com/p/mongoose/source/browse/examples/hello.c
I m not sure what you mean 'client side', if you are meaning Browser as your client, you can't control nothing outside your browser. If you want to control a machine, you need your client machine to run your exe, that has the code to act based on your server instructions.
You should create a simple server program, create a SOCKET listening on default http, https etc, ports. Usually we do it inside a loop (at each one you make a read).
Now... would be easer if you specified if you are on Unix like OS or Windows, but from now on you can google it. Like sys/socket.h or try "man 7 socket" on almost all linux (at least the ones I know).
If you want to sniff something you can google some specific apps around web.
If i get your question right, you want to be able to launch an application when someone clicks a link with a custom protocol, like steam:// or telnet://. You are looking for an Protocol Handler.
A simple way to register such an application is using the ftype program, as described here.
I have a web service running under IIS7 on a server with a host header set so that it receives requests made to http://myserver1.mydomain.com.
I've set Windows INtegrated Authentication to Enabled and everything else (basic, anonymous, etc) to Disabled.
I'm testing the web service using a powershell script, and it works fine when I run it from my workstation against http://myserver1.mydomain.com
However, when I run the same exact script on the IIS server itself, I get a 401-Unauthorized message.
In addition, I've tried installing the web service on a second server, myserver2.mydomain.com. Again I can call my test script fine from BOTH my workstation and from myserver1.
So it seems the only issue is when the client is on the same box as the web server itself - somehow the windows credentials are not being passed or recognized.
I tried playing with IE settings on myserver1 (checked and unchecked 'Enable Windows Integrated Authentication', and added the URL to Local Sites). That did not seem to have an effect.
When I look at the IIS logs, I see the 401 unauthorized line but very little other information.
I see basically the same behavior when testing with IE (v9) - works from my workstation but not when IE is running on the IIS server.
I found the answer after several hours:
By default, there is something called a LoopbackCheck which will reject windows authentication if the host header used for the site does not match the local host's name. This behavior will only be seen when the client is on the local host. The check is there to defeat possible reflection attacks.
More details here:
http://support.microsoft.com/kb/896861
The kb item discusses ways to disable the Loopback check, but I ended up just switching from using host headers to ports to distinguish the different sites on the IIS server.
Thanks to those who gave assistance.
Try checking the actual credential that is being passed when you are running on the server itself. Often times you will be running on some system account that doesn't have access to the resource in question.
For example, on your box your credentials are running as...
MYDOMAIN\MYNAME
and the server will be something like...
SYSTEM\SYSTEM_ACCOUNT
and so this will fail because 'SYSTEM\SYSTEM_ACCOUNT' doesn't have credentials.
If this is the case, you can fix the problem in one of two ways.
Give 'SYSTEM\SYSTEM_ACCOUNT' access to the resource in question. Most people would avoid this strategy due to security concerns (which is why the account has no access in the first place).
Impersonate, or change the credentials of the client manually to something that does have access to the resource, 'MYDOMAIN\MYNAME' for example. This is what most people would probably go with, including myself.
I'm monitoring a directory for FTP uploads on the server using a CF event gateway. Fine so far, but I want to get at the IP address of the computer uploading the file. The server is Windows Web Server 2008 R2 IIS 7 and Windows FTP 7.5
What I am aiming for is growl type message if the uploaded file has been handled correctly (or else error msg) and for that I need the IP of the sender. (there is no problem with NAT within the LAN)
The FTP service writes a log containing the IP which I could try to correlate with the directory monitoring event, but other than by scraping the log is there another way?
Since ColdFusion has no connection to the FTP service in IIS, you'll have to handle this through the logs. You can, however, use something like LogParser (see this article
from Ray Camden on how to use it to parse an IIS log file.
Good luck!
Dan