Search code examples
remote-accessiis-expressopenvpn

Bad request - Invalid Hostname IIS express when using VPN


I'm working on a ASP.net web application and I want to bind it so it can be used from a remote network through OpenVPN. I already have the connection with the network and I can ping my device from the other devices inside the network. This is the configuration I used for OpenVPN

client
dev tap
proto tcp
dev-node openvpn
remote 86.89.135.168 443
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client.crt
key client.key
cipher AES-128-CBC
comp-lzo
verb 5
push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"
#ifconfig 192.168.201.221 255.255.255.0
#route-gateway 192.168.201.1client

In the applicationhost.config I'm binding this:

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

I can access the application by localhost or by the local ip adress. But when I try to access it with the vpn ip from a device in the network I get this:

My firewall is off and even though it doesn't work. And like I said it works in other devices in my local network and in the host machine but it doesn't work with devices from the remove network.

Can someone help me solving this? I'm new at this.


Solution

  • I solved my problem by: 1.Adding my VPN executor as an Exclusive in the 'virus and threat protection settings'. 2.Adding it to “Allow an app or feature through Windows defender Firewall” (if its not in the list you got to click on "allow another app" 3.Add a TCP Inbound rule in the "Windows Defender Firewall with Advanced Security” to the port that you VPN will be using for communication. In my case it is 443.