Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parallels desktop: access local IIS web application from OS X (host)

I'am running Windows 10 on OS X using Parallels Desktop (network is in SHARED mode). I need to access web applications created on Visual Studio and running on IIS 10 from the host. For example for a generic application running on Windows at http://localhost:1654 I would like to access it from Mac browser with something like http://[ip_virtual_machine]:1654.

The first thing I did was to completely shutdown the Windows firewall, disabled it on public and private networks and also disabled the Firewall service in services.msc. Next I've checked the ip addresses of the host and the virtual machine. Running ifconfig on the Mac I get that the IP address of the virtual machine is 10.211.55.2 while running ipconfig on Windows I get that the IP address is of the VM is 10.211.55.3 (with gateway 10.211.55.1).

I've tried to access the web application using both http://10.211.55.2:1654/ and http://10.211.55.3:1654/ but with no luck. With the former I get a Bad Request - Invalid Hostname response, while with the latter I get ERR_CONNECTION_REFUSED.

In case the firewall was still doing something under the hood, I've also added an inbound rule to allow connections for port 1654, but same result.

I've also noticed one thing: in the applicationhost file in C:\Windows\System32\inetsrv\config\applicationHost.config there is not any reference to my web applications created in Visual Studio. AFAIK when I run a web application in Visual Studio on IIS the binding should be added to the applicationhost file, but there are no entries for any of my web applications. May I have some problems with IIS?

Another thing: the other way around works. I can access a node.js local server on my Mac from the virtual machine using http://10.211.55.2:[port].

But I need to access from Mac to Windows IIS. How can I do that?

like image 275
revy Avatar asked Feb 01 '17 09:02

revy


2 Answers

The accepted answer didn't work for me, but I finally had success after following the steps outlined here. My setup consists of Parallels 14 running on macOS 10.14.2, and Visual Studio 2017 running on Windows 10.

In summary:

  1. In Parallels, make sure your Network type is set to "Shared Network" and that "Share Mac applications with Windows" is enabled
  2. In your Windows VM, open PowerShell, enter ipconfig, and copy down your VM's IPv4 address. Then open Settings, go to System > About, and copy down your VM's device name
  3. In macOS, add an entry to your /etc/hosts file that maps your VM's IP address to its device name, e.g. 10.211.55.3 your-device-name
  4. Back in your Windows VM, in the folder for your Visual Studio project, edit the <binding> key in .vs/config/applicationhost.config (note that .vs is a hidden folder) to use your VM's device name instead of localhost, e.g. <binding protocol="http" bindingInformation="*:1234:your-device-name" />
  5. Open PowerShell as an administrator and run the following command to enable external access, using your VM's device name and the port from step #4: netsh http add urlacl url=http://your-device-name:1234/ user=everyone
  6. Open Windows Firewall and add new inbound and outbound rules for your project. For both rules, select "Port" as the rule type and "TCP" as the protocol, enter the port from step #4, and select "Allow the connection"
  7. In Visual Studio, go to your project's properties, click the "Web" tab, and change your project URL to use your Windows device name instead of localhost, e.g. http://your-device-name:1234/. Check the box for "Override application root URL" and enter that same URL again
  8. Debug your project using the "Open in Mac" browser. If you don't see this option, click "Browse With...", then "Add...", and then add an entry that points to C:\Program Files (x86)\Parallels\Parallels Tools\SIA\SharedIntApp.exe

Upon debugging, your app will launch in Safari (or whatever your default Mac browser is) at http://your-device-name:1234!

like image 109
daGUY Avatar answered Oct 27 '22 00:10

daGUY


Ok I got it working. The additional steps are:

1) Open CMD or Powershell as administrator. Add a URL ACL entry for the port you need:

netsh http add urlacl url=http://*:[port]/ user=everyone 

2) The applicationhost file with the bindings in my case is located directly inside the Visual Studio project folder. Specifically it is located at .vs/config/applicationhost.config. Open the file in a text editor and find the line with the bindings information for your application, something like

<bindings>
   <binding protocol="http" bindingInformation="*:1654:localhost" />                    
</bindings>

Add an another entry with the IP of your virtual machine, like this:

<bindings>
   <binding protocol="http" bindingInformation="*:1654:localhost" /> 
   <binding protocol="http" bindingInformation="*:1654:10.211.55.3" />                   
</bindings>

3) (** Optional: may not be necessary ***) In the applicationhost file, find the entry

<section name="anonymousAuthentication" overrideModeDefault="Deny" />

and change it to

<section name="anonymousAuthentication" overrideModeDefault="Allow" />

Now I can access the web app running on IIS from the Mac using http://10.211.55.3:1654 address.

Hope this helps.

like image 27
revy Avatar answered Oct 27 '22 00:10

revy