Browse Web Site With IP Address Rather than localhost - visual-studio-2012

I am using VS2012 with IIS Express and can not seem to browse my web sites using my IP Address. Is there some way to do that? It used to work fine with earlier versions of VS.
For example, this address works fine:
http://localhost:64651/
But, this address does not work.
http://192.168.252.165:64651/
I am sure of the IP Address, since I just got it using ipconfig.

Go to your IISExpress>Config folder, locate applicationhost.config. Change <bindings> as below:
<bindings>
<binding protocol="http" bindingInformation="*:1407:YOUR_IP_ADDRESS" />
</bindings>
Before you do this , you will have to register this IP address using netsh command as below:
Port forwarding in Windows 7
If you’re running Windows 7, pretty much all incoming connections are locked down, so you need to specifically allow incoming connections to your application. First, start an administrative command prompt. Second, run these commands, replacing 192.168.1.11:1234 with whatever IP and port you are using:
> netsh http add urlacl url=http://192.168.1.11:1234/ user=everyone
This just tells http.sys that it’s ok to talk to this url.
IMPORTANT: The user=everyone parameter must be specified according to the system language. So if your windows language is spanish the parameter must be user=todos.
> netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=1234 profile=private remoteip=localsubnet action=allow
This adds a rule in the Windows Firewall, allowing incoming connections to port 58938 for computers on your local subnet.More information at this link.
Port forwarding Mac OS X
Step 1: View Current Firewall Rules
sudo ipfw show
Step 2: Add Port Forwarding Rule (80 to 8080)
The default port that Tomcat runs on is 8080, so here we show the command to do port fowarding from port 80 to 8080 (Tomcat’s default port). Obviously, this works for other ports as well, and you’d just have to adjust the command accordingly.
sudo ipfw add 100 fwd 127.0.0.1,8080 tcp from any to any 80 in
This is a temporary change, and it will revert once you reboot. If you want to make it permanent, you can create a lauch deamon for it.
Optional Remove Rule
If you want to remove your firewall rules run:
sudo ipfw flush
Port Forwarding Using PFCTL (aka PF) on Mac OS X
The setup for pfctl is similar to ipfw. Github user kujon has created a nice guide to show how to set up port forwarding from port 80 to another port using pfctl.
Note: Be sure to change the bindings of your project only by locating its name. You can even keep the localhost binding and add a new one , this way you can access same webpage using both the given IP address and your old localhost binding.

You can use Conveyor by Keyoti
Step 1:
Download the Visual Studio Extension by searching for 'Conveyor' in the Tools->Extensions and Updates dialog.
Step 2:
Conveyor is automatically enabled for web application projects, run (debug) a project and note the Remote URL, that is the URL you will use from your device or other computer. Please see troubleshooting below if you don't see the Conveyor window.
Step 3:
Add an inbound firewall rule allowing access to the TCP port given in the Remote URL.
1. Open Windows 'Start' and type WF.msc.
2. Click 'Inbound Rules' on the left.
3. Click 'New Rules' on the right.
4. Choose 'Port' in the new dialog, then 'Next'.
5. Select TCP, and enter the port from the Remote URL next to 'Specific local ports' (probably 45455), then 'Next'.
6. Next, and next (you may want to disable 'Public'), give it a name like 'Conveyor: web dev server access enabled'.
Step 4:
Use the Remote URL from your device (phone, tablet or other machine) to directly access your application.
More information at Conveyor

binding visual studio in local iis ip webconfig

Related

Hosting a web site in IIS accessible from any web client?

Trying to host a web site on my local Win 10 Pro machine withing IIS, provided I share the IP to my friends. My host file contains something like:
127.0.0.1 site1.com
127.0.0.2 site2.com
127.0.0.3 site3.com
127.0.0.1:1 site4.com
127.0.0.1:2 site4.com
123.45.5.6 site5.com
123.45.5.6:33 site5.com
They all work as expected except for the imaginary external ip (only for example), and adding the port or not makes not difference. Seems i've tried what makes sense, say my external is '1.2" Creating a host entry like
1.2 # or
1.2:Port # the external IP with port
Also attempted adding an exclusion for he firewall to help ensure the traffic is allowed by doing:
netsh advfirewall firewall add rule name="Open Port" dir=in action=allow protocol=TCP localport=81
Kind of lost what might be missing, any suggestions?
Thanks for he help.
First. There is no need to add port after IP address in hosts file. Port can be configured on IIS by setting binding.
Second. If you want to allow any web client can access the site host on local WIN10 pro, you need to make sure WIN10 pro and web client are in the same LAN. Otherwise it is need to buy a public domain and bind to WIN10 pro device.
Using Ping command is a great way to test traffic between devices. It can help you make sure if web client can create connection with WIN10 pro.

Changing ssh port 22 to a custom port in azure resource group vm

may I know how to change ssh port 22 to a custom port in azure resource group vm? I know i can change the endpoints easily on vm classic. But how can i change ssh 22 to other port number for ssh on resource group vm on the new portal? thanks.
You can’t use the new type of VM with a resource manager on old portal so you have no choice but to use the new Azure portal https://portal.azure.com.
Let’s see what you will get when you create a new VM with a resource manager.
By default, you will get the following things when you create a VM but of course, you have an option to choose what to create or what to re-use during the setup.
•Virtual machine
•Network Interface
•Network Security Group
•Public IP Address
•Virtual network
•Storage Account
Choose “Network Security Group” then you will see the setting page that looks similar to Windows Advanced Firewall interface on windows server or desktop.
Click on “Inbound security rules”. This is where you can enable the endpoint of your new VM. Of course, you forget to open the same port in your server OS as well.
First you must do the following steps:
Once you are logged in to the server as root we can begin editing the sshd_config file. As with any modification to an important server file, it is always a good idea to back it up before making any changes:
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config_backup
Now we are ready to modify the file. Open /etc/ssh/sshd_config in your favorite text editor (for this example we will use Vim) and locate the line that specifies the port. If your sshd_config file has not been altered the Port setting will be commented out with a # symbol (example below).
sudo nano /etc/ssh/sshd_config
The # symbol tells the server to ignore anything after it on the same line, so we will need to remove that character and then change the number 22 to something else. Be sure you do not pick a port number that is in use by a different service. If you are unsure, Wikipedia has a list of port numbers and their uses. Try to use a port number that is not listed. For this example, we will use Port 2222 (which is used by Windows servers but not by default on Linux servers).
Remove the # symbol and change the port number
second you must do the following steps:
Go to your azure portal and select all resources
Choose “Network Security Group” then you will see the setting page that looks similar to Windows Advanced Firewall interface on windows server or desktop (see Figure 2).
Click on “Inbound security rules”. This is where you can enable the endpoint of your new VM. Of course, you forget to open the same port in your server OS as well. e same port that you put in the file /etc/ssh/sshd_config in destination port range (see Figure 3).
None of these fully worked for me.
I found a working answer on Youtube
https://www.youtube.com/watch?v=zkr-RMcGuk0
Which involved added the following redirect.
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2222 -j REDIRECT --to-port 22
Out of curiosity, why do you want to change the ssh port? The approach will depend on why you want to do it, but one way would be as follows:
ssh into the VM on port 22 and make the ssh daemon listen on whichever port you want. This link describes how to do it (you can ignore the part about iptables if you aren't using it): http://support.hostgator.com/articles/hosting-guide/lets-get-started/linux-dedicated-hosting/how-to-change-the-ssh-port-on-dedicated-and-vps
exit your ssh connection and ssh back in on your new port of choice
Alternatively, you could put your VM behind a load balancer that maps some other port to port 22 on the VM (e.g. https://azure.microsoft.com/en-us/documentation/articles/load-balancer-get-started-internet-arm-ps/#create-lb-rules-nat-rules-a-probe-and-a-load-balancer).
One important clarification to the portal answer is to make sure you specify a source-port-range of '*' for your inbound rule and a priority that is lower than the default rules. Typically 100-400 is a good priority range.
Unlike classic deployments, resource manager deployments don't have "endpoints" but rather inbound and outbound "rules" which is really a filter applied to the connection. The result is that the port you want to open to connect to the VM is the "destination-port-range", and the source-port-range specifies the "originating port for this connection", which is typically dynamic -- and thus, for most basic scenarios, should be "any" which is '*'.
The exceptions will be cases in which internally to your vnet you know that the originating port should ONLY be that one port, over there, on that one VM -- in order to be as certain as you can that only that VM/port can connect with this one.
But, in the case in which you want to connect from the internet, it typically needs to be '*'.
you have to add an entry in your ssh_config file
port = 22022
and then restart your sshd
sudo /etc/init.d/ssh restart
or
sudo service ssh restart
and then change the Azure portal NSG rules to allow port 22022 to your IP address or change the default ssh to custom and modify the port no.
and try the command if you are using password-based or password-less
ssh machine#host-ip -p 22022
or
ssh -i location-to-your-pem-file machine#host-ip -p 22022

Using ngrok with IISExpress on windows

I'm used to using a Mac, and ngrok is a breeze; all you need to do is specify a port, but I'm new to IISExpress, and I can't figure out how to use ngrok and/or IIS correctly. To be clear, I've inherited a Windows machine from a coworker (who has left the company) and the set up works great locally.
The local url is similar to:
thing.somedomain.com
In the bindings section of IIS, I've got:
Type Host Name Port IP Address
http thing.somedomain.com 80 *
I've used this page for reference: https://www.twilio.com/blog/2014/03/configure-windows-for-local-webhook-testing-using-ngrok.html
The instructions seem reasonable, but they don't work for me. These instructions indicate that the file applicationhost.config needs to be altered for IIS. I have found this file, and found the correct section for the site I need to ngrok. The binding info does not match what's in the IIS gui though:
<binding protocol="http" bindingInformation="*:4085:localhost" />
As per the instructions, I have added:
<binding protocol="http" bindingInformation="*:4085:whatever.ngrok.io" />
(Here every time I run ngrok on windows I get ngrok.io instead of ngrok.com, which seems odd. I've tried accessing both ways with no luck.)
I have restarted the site on IIS (in the actions menu). When I try to access the ngrok url from a remote machine, ngrok returns 502 bad gateway, and the remote machine shows:
Failed to complete tunnel connection
The connection to http://whatever.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:4085.
Make sure that a web service is running on localhost:4085 and that it is a valid address.
The error encountered was: dial tcp 127.0.0.1:4085: ConnectEx tcp: No connection could be made because the target machine actively refused it.
When I try to go to localhost:4085 locally, I get "This webpage is not available". When I try to go to localhost:80, I get a redirect to a different site the IIS is serving. When I try 127.0.0.1:80, I get a 404 error.
I have tried using netstat -a -b, and have tried all of the ports associated with 127.0.0.1, and nothing turns up the correct site (yet still thing.somedomain.com still works correctly).
I'm completely mystified, and don't know what to try next, or where the problem lies (in how I'm starting ngrok, in how I'm accessing ngrok, in how the bindings are mapped, in how IIS restarts, a firewall issue, or some other voodoo). This should be bloody simple!
So it turns out that there was nothing to change in the ApplicationHost.config file, AND I was looking at the wrong ApplicationHost.config file (the real file is normally hidden from view in C:/Windows/System32/inetsrv/Config, but you can open it in Notepad from a Command Prompt that has elevated privileges (Run as Administrator)). The actual binding info was:
<binding protocol="http" bindingInformation="*:80:thing.somedomain.com" />
Which is what matched what IIS was showing. That said, what I needed to change was how I invoked ngrok:
ngrok http -host-header=thing.somedomain.com:80
And that was it. I also allowed external traffic to the hostname with this:
netsh http add urlacl url=http://thing.somedomain.com/ user=everyone
There is a way to make it easier. Let's say your IISExpress website is http://localhost:63254
Just start ngrok like this:
ngrok http --host-header=rewrite localhost:63254

Can't connect to IIS Express using IP Address

From what I understand, VS2012 comes with the IIS Express version by default. And it allows you to connect to the development site using IP address. Currently I can connect using http://localhost:22222. But this would not connect using this http://xxx.xxx.xxx.xxx:22222 where xxx just a local IP of the development machine . I have verified that the IIS Express is running and being used. The IE error was http 400 bad request.
I know you have asked question since a long time. I have an answer to this question at this link.
Go to your IISExpress>Config folder, locate applicationhost.config. Change <bindings> as below:
<bindings>
<binding protocol="http" bindingInformation="*:1407:YOUR_IP_ADDRESS" />
</bindings>
Before you do this , you will have to register this IP address using netsh command as below:
If you’re running Windows 7, pretty much all incoming connections are locked down, so you need to specifically allow incoming connections to your application. First, start an administrative command prompt. Second, run these commands, replacing 192.168.1.11:1234 with whatever IP and port you are using:
> netsh http add urlacl url=http://192.168.1.11:1234/ user=everyone
This just tells http.sys that it’s ok to talk to this url.
> netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=1234 profile=private remoteip=localsubnet action=allow
This adds a rule in the Windows Firewall, allowing incoming connections to port 58938 for computers on your local subnet.More information at this link.
Note: Be sure to change the bindings of your project only by locationg its name. You can even keep the localhost binding and add a new one , this way you can access same webpage using the given IP address.
The solution that worked for me was this one:
The one thing that fixed this for me was using the following line in the <bindings> section for my site in the applicationhost.config file:
<bindings>
<binding protocol="http" bindingInformation="*:8099:" />
</bindings>
The key was to simply remove localhost. Don't replace it with an asterisk, don't replace it with an IP or a computer name. Just leave it blank after the colon.
After doing this, I don't need to run Visual Studio as administrator, and I can freely change the Project Url in the project properties to the local IP or computer name. I then set up port forwarding and it was accessible to the Internet.
EDIT:
I've discovered one more quirk that is important to getting IIS Express to properly serve external requests.
If you are running Visual Studio/IIS Express as an administrator, you must not add a reservation to HTTP.SYS using the "netsh http add urlacl ..." command. Doing so will cause an HTTP 503 Service Unavailable error. Delete any reservations you've made in the URLACL to fix this.
If you are not running Visual Studio/IIS Express as an administrator, you must add a reservation to the URLACL.
Where is it located? applicationhost.config :)
Here
%userprofile%\Documents\IISExpress\config folder
or
%userprofile%\My Documents\IISExpress\config folder

IIS7 access website from remote computer

i created a site on my iis7 it's like http://localhost:88/my
i also can access it like this http://myip:88/my
but when a friend of mine from a remote computer tried to access it like this http://myip:88/my it gives him 404 not found
anybody can tell me what should i do to make it work from remote ?
Check your firewall. You will have to open TCP Port 88.
Part 4: Opening Up to the Outside
World
Windows Firewall blocks the World Wide
Web Services port by default (Port
80). With this port blocked, other
machines cannot connect to your web
server. This severely limits the
scope of potential web site viewers.
So, in order to show your new web site
and server to the outside world you
must add an exception to the Windows
Firewall.
Click Start and type firewall into the Search bar and press enter.
(Note: Make sure you select Windows
Firewall and not Windows Firewall with
Advanced Security)
Click Change Settings
Click the Exceptions Tab and Scroll to World Wide Web Services
(HTTP).
Click the check box and click OK.
Now your machine is accessible to the
outside world. You can connect to
your machine by typing in the IP
address of your server into another
machine’s web browser.
source
If firewall setting is not the issue (say it's turned off), find out public IP of your server (ex. 192.168.0.152), then add it to http listener on the server itself
Open cmd and type:
netsh http add iplisten 192.168.0.152
Go Control Panel>System and Security>Windows Firewall>Allowed Programs-> then check all " World Wide Web Services(Http) tab"
Its is worked for me

Resources