Ports :80 and :443 traffic - networking

I am sorry if this question does not make sense but I am struggling to understand this topic. I have made an audio video style application that uses ports :80 and :443 but my senior developers worry is that it will not work because other applications also use ports :80 and :443 like skype and gmail.
My question is how do I get past this issue? Is it possible?
Again sorry if the question does not make sense
Thanks!

If you hosting your application, then it would not be problem. As you said other application like gmail etc uses the same port 80, i.e. means gmail server keeps listening on the port 80. When we access the gmail, any port is selected (1024 <) on client side. these ports are usually called as ephemeral ports
So when you access gmail, port say 41667 on your machine opened and connected to port 80 of gmail. port 80 inturn pass to other available port and keeps listening so many user at the same time can access gmail.

The convention for ports 80 and 443 is for http and https protocols.
Gmail listens on those ports, but it is sitting on a remote host, the local ports are random.
Skype do make use of those ports as an alternate configuration.
If you are coding both sides, you should consider other ports (>1024).
If you are relaying on users connecting to your server with regular http or https stay with 80 and 443, otherwise they will have to know the port and specify it in the http call (http://<YOUR_HOST | IP>:<PORT#>).

Related

Can network admin change the default port for http

I gave an answer to following thread. but in the comment a user suggested that network admin can change the default port of http from 80 to something else.
As for as I know if I open a page eg. http://www.example.com without port that means it is running on port 80.
I just want to clarify that is it possible for network admin to change default port?
When using a browser, http://www.example.com will always try and connect to the server's TCP port 80, like it's port 443 for HTTPS connections. These port numbers (defined here) are hard coded in any browser.
Yet a web server can be configured to listen to any other port, which rarely makes sense though. If it does, the browser will be unable to connect (unless the port no. is explicitly given as in http://myserver.com:81).

When is port forwarding necessary?

I've been investigating networking for use in a two-player game I'm writing, and I'm still not clear on when a device must have a port forwarded in order to communicate with the outside world.
From what I've seen in other games, port forwarding is always required in order to host a server, but is not required on the client. In addition, there are other situations, such as skype (which, to my understanding is ultimately client to client), where neither end must forward a port.
So my question is, in over-the-Internet communication, when is and isn't port forwarding necessary, and what steps can i take as a developer to make it so my users don't have to worry about it? Thanks in advance!
Port forwarding is needed when a machine on the Internet needs to initiate a connection to a machine that's behind a firewall or NAT router. If the connection is initiated by the machine behind the firewall, the firewall/router automatically recognizes the reply traffic and sends it to the machine that opened the connection.
But if a packet arrives on the external interface, and it's not a part of such a connection, the router needs to know what to do with it. By default, it will reject it. But if forwarding is configured for the port, that tells it what internal machine to send it to.
Put another way: you need port forwarding if you want to run a server behind the NAT firewall/router, you don't need it if you're just running a client.
There is reason why Skype don't (not always) need manual setting of port forwarding:
When you install Skype, a port above 1024 is chosen at random as the
port for incoming connections. You can configure Skype to use a
different port for incoming connections if you wish, but if you do,
you must open the alternative port manually.
If the port chosen for incoming connections becomes unavailable, by
default ports 80 and 443 will be used as alternatives. If another
application (such as Apache HTTP server or IIS) uses these ports, you
can either configure the application to use other ports, or you can
configure Skype to not use these ports.
Port forwarding is must if you host a server.
You can use same technique as Skype...
I am not sure if there is any other option...
Port forwarding (occurs) when a NAT, firewall or some other device blocks communication on all or some ports.
To answer your question as an example, most commercial routers use NAT to allow multiple people to use the same IP(As view from the outside world) provided by ISPs. Most ISP's use NAT to allow multiple customers to use the same IP(As viewed from the outside world). To get this to work, the NAT changes the internal IP and the port number of a communication to THE(there is only one for the entire sub network) external IP and a new port number. By doing this, the router/isp/ect can tell which internal IP and port each external communication goes to.
Anytime one of the computers communicating over the internet are behind a NAT, port forwarding is required. I'm sure there are way more situations than this, and the solution to each can be quite complicated. But this covers the vast majority.

Port forwarding

I have a simple requirement of hosting a webserver on my computer. But unfortunately, the internet connection provided by my employer has only ports 21 & 80 open. Rest of all the ports are closed. I tried port forwarding for ports 80 and 21 but they are already in use by my employer itself. So, is there any other way of hosting a webserver on my computer?
P.S.: I am on linux with Apache.
Does the firewall run an HTTP proxy, or is it just a simple port forwarder? If it's a proxy, it may be able to forward to different internal IPs based on the Host: header, similar to the way virtual web hosts operate.
If not, you won't be able to use these ports. A NAT router can forward a port to only one IP. If hosting the webserver is a job requirement, as you say, you should be able to contact the network administrator and get another port opened for it. If they won't do it on your request, your manager should be able to confirm the requirement.

Dynamic DNS port forwarding

I need to use my computer as a server but my ISP blocks port 80, 21, 23 etc. I can use other ports and some dynamic dns service but I don't want:
(HTTP) Users have to type http://mydynamicdnsaddress:#port#
(HTTP) Users be redirected from http://mydynamicdnsaddress to http://mydynamicdnsaddress:#port#
(HTTP) Some kind of service that gets HTTP response and change it before resending to users. No-ip and GoDaddy do that. They change some parts of html - eg: title.
Users have to type ftp://mydinamicdnsaddress:#port#
I believe that I need some kind of dynamic dns service that points to a router that forwards TCP packets to another address changing ports. Do you know any online service like that?
Many "dynamic DNS companies use HTTP redirection to send the browser from port 80 to a different port. When you ask a dynamic DNS company to point your domain to a port other than 80, what they actually do is point the domain to their own web-server IP address (in DNS), and then on their web-server (running on port 80) they have a simple server side script which redirects the browser to the your web-server on whatever port you specified - optionally "cloaked" so the visitor won't notice." Can I specify a TCP/IP port number for my web-server in DNS? (Other than the standard port 80)
Here's a reference article for a redirection script: Redirect Script.
What you are asking for is a tunnel or proxy. You'd set up a server which receives communications via port (e.g.) 80 and proxies that request to your home server on port-whatever. You'd probably need to get a dedicated host (or VM like linode) in order to do this. At that point, you might as well move your webserver to the unblocked host.
Also, to be clear, this is impossible with pure DNS. DNS, "Domain Name System", resolves names to IP addresses, NOT to IP address/port pairs.
Most dynamic DNS service providers also provide free web redirect or port forwarding such as dynu.com.
Please note that the cloak works by loading the page in a frame of sort and it does not work with all browsers. For example, Chrome does not support cloak.
As far as I know, you cannot specify the port number in the DNS unless the web server which performs redirection is clever enough to read out the TXT record and use it for redirection. Any web server doing that would be really nice though.

how can an application use port 80/HTTP without conflicting with browsers?

If I understand right, applications sometimes use HTTP to send messages, since using other ports is liable to cause firewall problems. But how does that work without conflicting with other applications such as web-browsers? In fact how do multiple browsers running at once not conflict? Do they all monitor the port and get notified... can you share a port in this way?
I have a feeling this is a dumb question, but not something I ever thought of before, and in other cases I've seen problems when 2 apps are configured to use the same port.
There are 2 ports: a source port (browser) and a destination port (server). The browser asks the OS for an available source port (let's say it receives 33123) then makes a socket connection to the destination port (usually 80/HTTP, 443/HTTPS).
When the web server receives the answer, it sends a response that has 80 as source port and 33123 as destination port.
So if you have 2 browsers concurrently accessing stackoverflow.com, you'd have something like this:
Firefox (localhost:33123) <-----------> stackoverflow.com (69.59.196.211:80)
Chrome (localhost:33124) <-----------> stackoverflow.com (69.59.196.211:80)
Outgoing HTTP requests don't happen on port 80. When an application requests a socket, it usually receives one at random. This is the Source port.
Port 80 is for serving HTTP content (by the server, not the client). This is the Destination port.
Each browser uses a different Source to generate requests. That way, the packets make it back to the correct application.
It is the 5-tuple of (IP protocol, local IP address, local port, remote IP address, remote port) that identifies a connection. Multiple browsers (or in fact a single browser loading multiple pages simultaneously) will each use destination port 80, but the local port (which is allocated by the O/S) is distinct in each case. Therefore there is no conflict.
Clients usually pick a port between 1024 and 65535.
It depends on the operating system how to handle this. I think Windows Clients increment the value for each new connection, Unix Clients pick a random port no.
Some services rely on a static client port like NTP (123 UDP)
A browser is a client application that you use in order to see content on a web server which is usually on a different machine.
The web server is the one listening on port 80, not the browser on the client.
You need to be careful in making the distinction between "listening on port 80" and "connecting to port 80".
When you say "applications sometimes use HTTP to send messages, since using other ports is liable to cause firewall problems", you actually mean "applications sometimes send messages to port 80".
The server is listening on port 80, and can accept multiple connections on that port.
Port 80 you're talking about here is the remote port on the server, locally browser opens high port for each connection established.
Each connection has port numbers on both ends, one is called local port, other remote port.
Firewall will allow traffic to high port for browser, because it knows that connection has been established from you computer.

Resources