Application Server and Web Server on Two Different Machines - webserver

Today I'm hosting a Laravel v4 web application on a MacMini. Why a Mac? Because I created the application logic in Objective-C (leveraging my experience with iOS dev). Whether or not this was the right choice isn't the point of the question.
What I'm interested in knowing is how can I separate my web and application server. For instance, if I put my web server on Linode (or whatever) how do I go about communicating back and forth between the web server and the application server? Is there some sort of resource I can look to to understand how to do this?

Assumptions
Here's some assumptions I'm making:
I'm guessing Laravel and the Objetive-C Application are part of the same "system" and so I'm just gonna treat this as if you need a web server to send requests to a PHP application.
The Linode server will be a web server which sends request to the PHP application (Laravel)
Hosting PHP Applications
There are three moving parts:
The web server (Apache, Nginx)
The application gateway (PHP-FPM)
The application
The gateway and the code must live on the same computer/server. The web server can live on a separate computer/server.
This means you'll need your Macintosh to run PHP-FPM, which can then listen for remote connects and send them to the PHP application.
Macintosh
Install php-fpm on your mac. Make sure it can listen for remote network connections. This is usually done in the www.conf file in the listen directory, you can listen for connections on the remote network interface (whatever IP address the computer is assigned).
Linode
Install Nginx or Apache and have it proxy FastCGI requests off to your macintosh server at the macintosh's IP address (the one you set up to listen to addresses in the step above).
Firewalls
You may need to ensure the firewalls at both ends allow incoming/outgoing connects on the networks being used to communicate to eachother.

Related

Web sockets and Rest API in same Tomcat based application

I have read up on web sockets providing full duplex connections over TCP which can be used in scenarios where long polling was used to get live updates to client from server. Now I have a Tomcat based application which serves multiple REST based web service response, and I want couple of API's to be implemented using web sockets say to render dashboard with latest data where multiple users are working on them concurrently, is that possible ? My concern here was even if the connection was upgraded to TCP from HTTP wouldn't web socket require a separate port to run than the default Tomcat port 8080. In that case should I house the Web Socket based endpoints separate to the Tomcat based application already running. Please do correct me if any of the above is wrong.
A couple of month ago, I wrote a small Spring Boot webapp with embedded Tomcat that provides both, REST endpoints and websocket support, and both via the same port. So, yes that works... if you wanna sneak a peek: https://github.com/tommybrettschneider/pinterest-boot
Besides that, this post should also clarify things:
Shall I use WebSocket on ports other than 80?

Is it possible to run a Golang REST web app on an internal (private) IIS server?

I would like to create a web service with GoLang that runs either on IIS (7, 8 or 10) or under Tomcat 7.0. We have multiple environments, each with multiple servers, all being Windows 2008 R2, 2012 or 2016. All servers are private (10.x). My goal is to add some REST services to a COTS product that uses both IIS and Tomcat. I'd prefer to avoid gluing nginx or something else onto either server at the risk of impairing the COTS product or having their tech support people not answer the phone. Again .. the servers are only accessible via corporate VPN and are not public internet-facing.
Which server would offer the easiest path to get something working -- Tomcat or IIS?
That's not really about Go, but still there exist at least two solutions I can think of:
Reverse proxying of HTTP requests.
Write a plain Go server serving requests via HTTP.
Maybe turn it into a proper Windows service using golang.org/x/sys/windows/svc.
Deploy it.
If it's to be hosted on the same machine which runs IIS, then it's fine to make it listen on localhost only. Note that it will need a dedicated TCP port to listen on, and you'll need to make it possible for your server to be somehow configurable in this regard.
Set up reverse proxying in your IIS so that it forwards requests coming to whatever (part of an) URL you want to the Go server.
Use FastCGI.
Go supports serving requests over the FastCGI
protocol by means of its standard library,
and IIS suports FastCGI workers.
So it's possible to (re-)write your Go server to use FastCGI
instead of HTTP and then hook it into IIS via this protocol.
The pros and cons of these solutions—as I view them—are:
Serving over plain HTTP is more familiar to a developer and
makes the server more "portable"—in the sense it will be easier to change its deployment scheme if/when you'll need it.
Right to making it available to the Internet directly.
Conversely, with FastCGI, you'll always need a FastCGI host as a "middleware".
There were rumors that HTTP code is more fine-tuned in terms
of performance than that of FastCGI.
Still, this only will be of concern for reasonably hard-core loads.
One possible upside of FastCGI over HTTP is that it can
be served over pipes rather than TCP. For instance, you might
get it served over named pipes as it's supported by IIS's FastCGI module and there exists 3rd-party packages for Go implementing support for them
(even including one from Microsoft®).
The upside of this is that pipes are beleived to incur lesser overhead for data transfer (basically it's just shoveling bytes between in-kernel buffers belonging to two processes instead of pushing them through the whole TCP/IP stack), and using pipes frees you from the need of dedicating a TCP port to the Go server.
Still, I have no personal experience with this kind of setup and its performance trade-offs.

Configuring NetGear router with PHP Front End?

I have a netgear router and a PC that functions as the server. On the server I have a website that is hosted on a WAMP solution (windows, apache, mysql, php). Linux is an option, but Windows is first prize in this specific scenario.
What I need:
If someone connects to the wireless network, the splash page that is hosted on the server must be displayed.
All users must have bandwidth limits that are configurable for each user
I must be able to interact with the router via PHP code, in order to execute certain functions when certain users logon, etc.
So, my question is, how do people normally do this? Is there a way to configure this on the router (users connect to ROUTER), or is this something that can only be accomplished with a PROXY (users connect to proxy on server, server connects to internet via router).
Is this possible? Is there software available that does this? Is a proxy what I really need?
If your router supports it, you can install DD-WRT onto the router and use NoCatSplash to capture the connected user's first HTTP request and redirect it as needed.

Fiddler for website running on remote machine

I need to monitor a http request and response for web site running on remote web server. The web server makes lot of web service call and would like to trace them.
If the web site was running locally, Fiddler traces every web service call request and provides me with a report. Could someone please help me with how the same is possible
*e.g.
If the web application is running locally and calls two web services fiddler shows the total time on statistics. However, if the web application is running on web server hosted on different web server hosted internally (intranet) and I ran fiddler on my machine, I don't get the statistics for each web service call. All I can see is the total time for the aspx page.*
So question is how (if possible) can I trace the statistics of each web services invoked by web application that's running on different machine and fiddler is running on my machine.
Thanks.
You could always use WireShark http://www.wireshark.org/ to catch all the packets, if you are on the same network as the server, that is.
Say you're running a website on port 80 of a machine named WEBSERVER. You're connecting to the website using Internet Explorer Mobile Edition on a Windows SmartPhone device for which you cannot configure the web proxy. You want to capture the traffic from the phone and the server's response.
0.)Start Fiddler on the WEBSERVER machine, running on the default port of 8888.
1.)Click Tools | Fiddler Options, and ensure the "Allow remote clients to connect" checkbox is checked. Restart if needed.
2.)Choose Rules | Customize Rules.
3.)Inside the OnBeforeRequest handler, add a new line of code:
if (oSession.host.toLowerCase() == "webserver:8888") oSession.host = "webserver:80";
5.) navigate to http://webserver:8888
Requests from the SmartPhone will appear in Fiddler. The requests are forwarded from port 8888 to port 80 where the webserver is running. The responses are sent back through Fiddler to the SmartPhone, which has no idea that the content originally came from port 80.
You can setup Fiddler in your machine and set it as a proxy in the web application you want trace. Easy inside a network, not so easy accross the interwebs.

Does an application running via Citrix listen on local interfaces?

Let's say you have an application that listens on a socket on all network interfaces on a machine and displays the messages it receives on a UI. If I run this application on a client machine via Citrix (Presentation Server?) would the application also be listening on the network interfaces available on the client machine by default. If not is there a way to make that work?
If you run the application via Citrix, it is executed on the Citrix (XenApp / Presentation) Server and listens on the server.
If you would rather have the application listen on the client but be executed on the server, you could use the virtual channel SDK to pass data between the server and the client. You can find more information in an earlier answer.