I've read many posts on the internet including stackoverflow about how webserver works. Answers differ from each other in the posts. I really wonder what is the most correct answer on that topic.
User IP: UI
User Port: UP
Server IP: SI
SERVER PORT: SP
PROTOCOL: P
Scenario:
I want to visit www.example.com/file.php (IP: SI and PORT: SP)
TCP Connection established between user and server
In the server site, Apache listening on the SP port all the time.
The http request from browser /GET file.php
Apache finds file.php and want php to proccess it and send it back to
apache
Apache retrieves output from php and send it back to user
User browser renders it at application level.
This is what I know, what I don't understand here, how does Apache behave when multiple connection made. Does Apache creates new thread for every connection? If so, how do those threads communicate to the users?
I hope my question was clear. Thank for anyone helping me understand this concept.
Related
Can someone please explain how the server differs between the two requests www.google.com/maps and www.google.com/inbox?
It's best for you to see for yourself. If you're on Linux/MacOs, go to a shell and type nc -l 8080. Then open a web browser and look at, say, http://localhost:8080/a/b/c/d.
The nc command listens on port 8080 and just prints out whatever it receives. Here it's serving as a bad web browser that listens for requests but has no idea how to respond.
You'll see that the first two lines of what it receives are:
GET /a/b/c/d HTTP/1.1
Host: localhost:8080
followed by other information the browser things the server might need.
I am trying to get my head around Windows, Networks and Domains.
I currently have a server - svr. This is on my domain companyname.co.uk
I can connect to server and ping both svr and svr.companyname.co.uk.
On this server I have a number of applications with web access; TeamCity, Octopus etc. We currently connect to them by browsing to svr:xxxx where xxxx is the port of the web app host (http://svr:9090/ for TC)
I want to create friendly alias' - for example teamcity.companyname.co.uk would point at svr:9090, octopus.companyname.co.uk would point to svr:8090.
However, not being experienced in this area I can't seem to find relevant documents or sites that fully explain what I am looking for.
First, to make one thing clear: when you visit a web page like http://example.com, your web browser is actually making a request to example.com:80. This is done transparently because port 80 is the standard port for the HTTP protocol. As you know, you can request a non-standard port by appending it to the domain name in the URL: http://example.com:888/.
Unfortunately, you cannot have a domain name "alias" that somehow includes a non-standard port - your browser will always try to use port 80 if you don't specify a port.
One solution would be to use a proxy - nginx, apache, lighttpd, and others can all do this.
The idea is that you set up a proxy server that is listening on port 80 on your host. It waits for connections, then forwards those connections to a different server (on the same host, or on a different one) based on some rule. So, for example, you might have rules that look something like this:
IF host = teamcity.companyname.co.uk THEN forward to teamcity:9090
IF host = octopus.companyname.co.uk THEN forward to octopus:8090
The syntax for these rules vary widely between different proxy configurations, so this is just an example.
Note that this is not a redirect - the user's browser connects to teamcity.companyname.co.uk for all requests. It's the proxy that sends the request on to a different service and forwards any responses back to the client "behind the scenes".
These proxy configurations can get quite complex. For example, what if your teamcity application serves a page with a link on it that points to http://teamcity:9090/path/to/page? The user's browser is going to fail if they click on that link. Fortunately, proxies can be configured to rewrite URLs like this on the fly. You'll need to do some research to tailor this solution to your situation.
For my academic project, I am trying to achieve this.
A web server node JS application listening on port 3000.
So If you curl http://localhost:3000 you will get Hello World!. ( A simple web page.
Now I am running above webserver in my local machine. And my modem is behind NAT. Suppose If I port forward in the modem to myip:3000 then it is open to the world. But here is the biggest thing I am stuck - I don't want to use the modem for port forwarding, instead, I will use third party server for UDP Punch Hole.
Now my requirement is anyone from net should able to access my webserver at curl http://third-party-server-ip:3000.
What I am trying is to write another client - which opens a connection to the third party server. Say it did a hole punching at port 41234. That port is open. The third-party host can send something to that port.
Now anyone in the internet initiate this command curl http://third-party-ip:3000 to the third party host. So the third party returns the myip:udpPunchHolePort i.e., myip:41234.
anyone will again curl to myip:41234 it will be received by the node js UDP punch app, so it will redirect to localhost:3000. Finally, the anyone will receive the response from localhost:3000.
My two questions -
Is there any better way than the one I proposed here?
Is there any well-known node-js lib for this kind of stuff, I see,
I can use UDP punch hole. Or I am thinking to write a Lib to do this in general - does this sounds like re-inventing the wheel?
Note -
In this academic project, we are trying to learn how to make any local application open to the world without port forwarding in the modem.
We read on skype protocol analysis, that is also our inspiration.
No, that won't work.
HTTP runs over TCP, not UDP. Punching a UDP hole doesn't do you any good -- any TCP connection to the backend HTTP server will still fail.
HTTP redirects are not magic. If a user cannot access a specific host:port, redirecting them to a URL on that host:port will just make their browser time out when it requests that URL.
You cannot send a response from a different host:port from what the browser requested, because there is no TCP connection established with that endpoint.
I'm not sure whether to ask this question on a programming forum or linux administration forum as it involves both programming with web sockets and server admin. Basically I am trying to follow this guide "http://41j.com/blog/2014/12/simple-websocket-example-golang/". I have a centos basic server that has a static IP and I've port forwarded it to ports 22 and 80 (ssh and http). I can compile and run the server app fine, but i cannot connect the client. I'm currently out of ideas since I've never messed with networking before. I read somewhere that html5 websockets go through ports 80 and 443 when given an external IP. What I want is to start the server app on port say something like 1445 and then lets pretend my external IP is 244.214.21.44 and then have client connection string look like 'ws//244.214.21.44:1445/echo'. What am I missing, do I need to install apache or something?
Thanks for reading.
i have a flash game hosted on domain a.com which connects using sockets to a game server on domain b.com on a certain port other than 80.
now this doesnt work. the connection cant be established and i assume this is because of cross-domain security in flash-player.
now i have read that this problem can be solved with a crossdomain.xml file. but i dont quite understand where i have to put this? on domain a or domain b?
domain b doesnt even have port 80 open since that game server is listening on a custom port.
thanks!
I'll direct you to the official documentation. If you still have any doubts, please just let me know and I'll do my best to answer them. From your question, you want to know where the crossdomain file is hosted, the basic setting is that it should be hosted on the source domain, that is domain a, in the base of the host (a.com/crossdomain.xml).
Here's the base documentation file:
http://learn.adobe.com/wiki/download/attachments/64389123/CrossDomain_PolicyFile_Specification.pdf?version=1
A few specific guides that should help you:
http://www.adobe.com/devnet/flashplayer/articles/cross_domain_policy.html
http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html