IIS Reverse Proxy Rule From Different Ports - iis

I've been trying to make a Reverse Proxy rule in IIS for when a specific port is used to access the site. For example:
I want to be able to set up multiple rules, one for port 80 and one for port 8080 so that if port 80 is accessed through http://example.com one rule is triggered and if it is accessed through port 8080 as in http://example.com:8080 then a different rule is triggered. The Input conditions for the rules don't seem to allow for this as it says the Input is "URL path after '/'".
Is there a way to do this?
Many thanks in advance.

Just realised that you can specify additional conditions for the Inbound rules.
So you can use one of them and check if {SERVER_PORT} matches against the port number you care about. This appears to work for me.

Related

How can I remove the port from the url?

I want to hide my port number in NodeJS,
for example:- I was running on a port 4001,if I want to make a request for '/xyz' webhook I need to make a request as 'https://example.com:4001/xyz' in this I am not interested to show my PORT to others I want to mask or hide it from the public it should be as "https://example.com/xyz"
Please help me to setup as above
I'm assuming your using localhost to serve your app. Once you deploy to the web, the port number will be handled automatically as all http requests are routed to port 80 by default.
May be you have given port number in your code. just remove that, instead keep process.env.PORT or process.env.PORT || 4001. so that the server will take port 80 by default.
now you no need to add the port number while visiting the url.
tldr switch your nodejs app to run on port 80.
The existing answers are all correct but none explain the why. The HTTP protocol (your site is a http server) uses port 80 as a default, yet you are running your server on port 4001 so it needs to be explicitly stated. If you go to http://example.com you are actually making the http request on port 80, it just doesn't need to be explicitly stated as that is the assumed default. There is no difference between http://example.com:80 and http://example.com.
That being said there is no security need to "mask" or "hide" your port. If you switch it to 80 it isn't hidden it just doesn't need to be typed. The only reason to make this switch is because it is easier, shorter, makes your site look more professional ect.

Make a subdomain to point on a specific port

I already checked some topic about it but didn't find any solutions (if it's possible). I have a domain that points on my server on the port 80, but, I have another important webservice running on the port 8080.
I want to know if it's possible to create a subdomain like (admin.example.com) which points on port 8080.
Thanks
The simple answer is no. The server name is resolved by a DNS query to a single IP, to which port the connection is made is between the application and the server. For HTTP the conventional default port is 80 and HTTPS 443, if you need to use another port, you need to include it in your URL.
SRV entries in a DNS record can be used so resolve a hostname to a specific port, but this works reliably only for a handful of protocols that mandate its use.
Currently the preferable way is to set up your server with a reverse proxy to direct traffic by a specific server name (your subdomain, carried in the request headers) to your admin service. This is quite easily done using e.g. nginx.

Is it possible to bind port 443 to HTTP on IIS?

Is it possible to use port 443 on http?
I am adding a new binding as http on 443. There is no other bindings as well. But IIS can not be started. It says that another web site may be using the same port.
I use nestat. But I could not find a solution.
Thanks for your help?
I found a solution but I am not sure. There may be side effects.
I changed IP address of the binding in site bindings dialog box on IIS. Instead of all unassigned I used specific IP address.
"HTTPS URLs begin with "https://" and use port 443 by default, whereas HTTP URLs begin with "http://" and use port 80 by default." Source: Wikipedia, HTTP Secure/HTTPS. Port 443 is categorised as well-known port.
It's yet another limitation imposed by the IIS Manager GUI, you can bind to *:443 over HTTP using the appcmd.exe CLI tool!
Or as you found out, bind to just a single IP instead of all from the UI

How to temporarely resolve a name to a localhost port?

I develop websites with rails, and I was looking for a simple way to setup a dynamic name resolution for my app. The final product I need is to is: Every time I start a rails application (by typing rails server on my application folder, I want to run it on a random port and if I type the application name on my browser (like myapp.dev or something) it resolves to the localhost on the correct port.
The part of getting the app name and generating a random port is not the problem. The problem is how to resolve a name to a local port. Is there any simple tool on linux that allows me to do this?
Right now, the best I can think off is start a daemon that keeps track of when a rails app is started, annotate the port, and add an entry to itself in /etc/host with the app name. Then, whenever it receives a request, it forward to the correct app based on the name.
I can't believe this is the best way so ideas are highly appreciated.
I'm not sure if I understand your problem correctly, but DNS it not about ports. By using DNS you can resolve the name to IP not port or from IP to name (RevDNS). What you would do in your case is during start up of application on random port, forward another port which will be always the same.
For instance:
By iptables forward port 80 to random port of your application. Then you will always get to application by port 80.
Edit: I couldn't paste it in the comment because it's too long, so I give you answer here:
You can create a lot of iptables rules and first application will be on port 80, next 81, and so on.In browser you have to type then: apps.test.com (first app) , apps.test.com:81 (second app)..
Another solution: if you want to have diffrent domains (not type a port after colon), you can use proxy server,
and use VirtualHost to redirect to particular apps. In proxy configuration you can define that app1.test.com goes to port e.g 8888, app2.test.com goes to port 8889 and then during start up your app you can create iptables rule or ssh tunel to redirect whole traffic from port 8888 to your random port of
ruby application. To don't do it more complicated, it would be nice that these port
which you configure in proxy, are not used by your ruby application. Also you can check, iptables
"string match" option; Match Host field of HTTP request and then analogously during start up apps,
create iptables rule which will redirect everything which goes to port 80 with specify Host field to
your ruby app port. The last option would be using SRV dns record, but it's rather useless in your
situation. But anyway you can play around with all of these options, and choose one which is the best for
you.

How can I set a specific application to use a different port in IIS7?

I want to use a port other that port 80 for a specific application. (It's the speedtest.net mini app: http://www.speedtest.net/mini.php).
I want to use a port other that 80 for it, as we have a WAN optimisation tool on the network. As such, in order to get a "true" test (without the traffic having been cached or compressed) I need to add an exclusion rule in the WAN optimisation too for every host I want to run the test on. (If I stop optimising http traffic for all hosts it would defeat the point of the WAN optimisation tool!)
It would be much easier if I could run the test from some arbitrary port as I could then do a rule for all hosts on this port.
I can see how to edit the bindings for the Default Web Site, but not for a single application. (Or if I set another port up would this ripple to all applications, but wouldn't matter as they'd still be accessible on Port 80, too.)
End result is that I want to get to all my sites on port 80 except one:
http://myserver/speedtest:8765 (or some other port)
You have to go in Control Panel -> Windows Firewall -> Advace Settings -> and then Connecting Rules ( or something like that).
And it will load a list of all your program where you can change port and everything.

Resources