In some windows machines, after stopped the IIS site which running in 80 port number, still that port number is in use. This issue randomly reproducing in few machines.
Is there a way to stop this port number using C#?
There is a difference between stopping a website and releasing a port.
IIS could have several sites listening to port 80, all with different host headers.
Stopping a site just means that request's aren't being handled. Try stopping the application pool.
But the ports are in use by the kernel (HTTP.sys) so no guarantee about releasing them.
Related
I want to run multiple web server on the same VM. Each web server is dockerized.
Is it possible to run multiple dockerized web servers on port 80, with different domains, using docker functionalities?
I found many solution based on NGinx proxy like here , but I don't find any user defined network usage that solves this problem.
Is there any solution to this problem without running a reverse proxy?
No.
There is only one "real" port 80 on the host server (for each network address), so you need something that listens there and forwards to the different backend servers.
This is not a docker-specific problem. You cannot run multiple (non-Docker) web servers (one for each domain) on a single port either.
That something does not have to be nginx.
As far as I am aware, no it can not work to have multiple containers listening on port 80 or the same port in general.
You could open up different ports on your VM and have the applications listening to each one of those ports specifically.
For instance you could have your first application listen to port 80. Then your second one on port 81, etc.
First of all it is possible to run multiple domains on the same port, but the requirement is that:
you host sites on the same web server (Apache HTTPD or Nginx)
you are using virtual hosts
The one server can be containerized, if needed.
Here is the example of running two domains on exactly one Nginx web server.
So depending on your requirements, that can be solution.
I have a nodejs application running on port 3000. I wanted to host it on Linux environment. So I installed nodejs in it. It's working fine but I should specify the port each time.
example: mydomain.net:3000/url_i_want,
How can I avoid this. and also when running my app like that, all users are kind of connected to each others. If one of them disconnect all other users are. If one of them change page all others have there pages changing. Is it because they are all listening to the same port 3000 ? I searched and found that it can be related to PM2 and Nginx. Is it the solution ?
Whenever you load a URL without specifying the port number, the browser defaults to 80, because 80 is the default port number for HTTP.
So if you load http://stackoverflow.com/questions, the browser "converts" it to http://stackoverflow.com:80/questions.
If you don't want a port number to be specified to access your website, your app should be listening on port 80, instead of 3000.
However, it is not recommended for Node apps to directly listen on port 80 (although they very well can).
What you can do is use a front-facing proxy such as nginx, which accepts connections to the host's port 80, and then redirects the request to localhost:3000, where your app is listening.
It is best to ask one question at a time.
As for your second question, unless you are using some sort of "remote syncing" framework, that sort of behavior is unexpected. I would suggest posting a separate question for that issue with more details about it.
I installed TomCat using the default port: 8080. The hosted application started to get some significant use. Today I got an email from someone else who says that their network security rules do not allow them to access any web server that is not on port 80.
I resolved the issue by running TomCat on both port 80 and 8080, however, I keep thinking how silly this "security rule" is. Clearly, harmful servers can be run on any port, including port 80. Does running a server on port 80 make it in any way more trustable? I am assuming that this rule was created at one time long ago when someone found a rogue server running on a non-80 port, and decided the best way to prevent this was to block all HTTP servers that are not on port 80. In other words: an inappropriate over-generalization.
Perhaps I simply am not aware of it, but is there some valid rationale for restricting users to only access web servers on port 80?
In the past there was an elevated risk of phishing/pharming attacks using high-port web servers, though these days it really isn't an issue. The reason being was that in order to bind a listening socket to a lower order port on a *nix machine, you had to be root. Attackers without root could phish or otherwise somehow direct users to point their browser at the evil listening socket and receive a payload. These days the scenario described rarely if ever occurs.
It is also possible that an admin in the past sought to impede a user connecting to a proxy. Proxies commonly listen on port 8080 for web requests. If your organization has a policy that can be complied with by having this rule, then that may be the reason for its existence.
I personally see that rule as an annoyance rather than an effective filter. Nowadays there are much better tools that do smart filtering so you don't have to rely on security through obscurity tricks like restricting HTTP to port 80.
We're re-writing our services from ASMX -> RESTful using ServiceStack so there's a short term need to keep IIS and classic services running on port 80. Also, some of our customers host more than one web app (e.g. company intranet) under IIS listening on port 80.
My application needs to be distributed to hundreds of customers, so I'd like to move away from the IIS dependency in the interest of making my deployment of updates simpler - if possible. We also have many customers who have setup special forwarding in their routers for port 80, so listening on a different port for SS services would cause a lot of deployment pain - not to mention most firewalls are more lenient with port 80 traffic.
I have two possible related issues:
1. When I can get SS to fire up on port 80, I get "handler not found" for routes that would otherwise work on another port.
2. While debugging (start / debug / stop / restart), eventually a listener registration appears to "stick" and I end up getting:
System.Net.HttpListenerException (0x80004005): Failed to listen on prefix 'http://*:80/' because it conflicts with an existing registration on the machine.
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()
at ServiceStack.WebHost.Endpoints.Support.HttpListenerBase.Start(String urlBase) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\Support\HttpListenerBase.cs:line 122
at FieldCommService.FieldCommService.ConfigureServices() in e:\Development\Source\Hg\fieldcomm\src\Services\FieldCommService\FieldCommService.cs:line 305
at FieldCommService.FieldCommService.Startup() in e:\Development\Source\Hg\fieldcomm\src\Services\FieldCommService\FieldCommService.cs:line 84
I won't rule out hosting the service under IIS as a solution, I just prefer not to take on/continue to take on the configuration and deployment pain IIS comes with.
I have two questions:
1. Is listening on :80 as a self hosted service possible [with AppHostHttpListenerBase]?
2. In the intellisense for AppHostHttpListenerBase, it's noted that this class is designed to allow listening on port 80 next to IIS, but that "admin user privileges" are required. What does this imply under Windows running as a Service? An identity belonging to the Administrators group? Or simply "Local System"?
Prologue: I am running windows Server 2008 R2 on a Virtual Machine. This virtual machine image has been happily hosting TeamCity on port 80 for several weeks. This TeamCity server is accessed by others on the network by visiting a url (pcname.domain.com).
The Issue: It seems corporate decided to push some updates to my machine over the weekend. It seems this round of updates decided to install/update IIS. Low and behold, visiting the URL mapped to the TeamCity server actually takes me to the stock IIS7 page. Visiting url/login.html brings me to the TeamCity log-in page.
Attempts: First off, I changed the TeamCity port to 8080 and was able to access it at url:8080 (or localhost:8080). However, it is imperative to me that people can access the server without providing a port... so I change TeamCity server port back to 80 and set off to try and fix this IIS problem.
Since then I have uninstalled IIS7 by removing the role and services from Windows - I am now hosting "0 roles". I have removed every trace of IIS from my PC, but visiting localhost still gives me 404 not found (instead of server not found or just my TeamCity page).
My Question: How do I prevent Windows Server 2008 from trying to host some default crap on port 80 so that my TeamCity server can be seen again?
EDIT: After performing netstat -ano, the only PIDs associated with port 80 are '0' and '4' (system and svchost!)
In windows the usual suspects using port 80 are IIS itself, and maybe the Web Deploy Agent Service if installed (but it could have any other app bound to that port). The PIDs 0 and 4 just tell you that the applciation using that port is running as a service. If you do not need any of this (IIS, web deploy, etc), go to Services and disable them, the port should be free to bind after that.
You can use net sh http show servicestate | findstr HTTP to reach the address and port binding information.
A simple solution (one that I am also using in a production server with multiple apps) is to set up a proxy based on either the domain or the URL path itself (see here how to with nginx).
Hit command, netstat -ano in an elevated command prompt to see what applications are listening on which ports. This command will show you the PID of the process that is listening on port 80. Now, open the Task Manager -> Processes tab. From the View -> Select Columns menu, enable the PID column, and you will see the name of all the processes those are listening on port 80. You can kill the listed tasks. Mostly applications like, World Wide Web Publishing service, IIS Admin Service, Web Deployment Agent Service may use the port 80 in Windows Operating System.