How to give public access to the Net Core 6 site in IIS by a static IP address?

Volk Volk 551 Reputation points
2022-10-11T11:18:29.5+00:00

Hi!

I have launched a Net Core 6 website on Windows Server 2022. It runs on the server in the local version on ports 82 and 443 (http and https). The domain name has not yet been redirected to this server from the provider, but in the local version I use it instead of localhost. Everything is fine, everything is working. But how do I open access for this site so that it is visible from the outside by static IP with the indication of the port - for testing, verification and filling? For example, I need to type in a browser on any computer a string like http:\<IP>\<domain>:<port> and work with the site as usual?

I could not find this information on the Internet, but I know that this can be done. How to implement it? Do you have links to step-by-step instructions?

Thanks!

Windows development | Internet Information Services
Developer technologies | ASP.NET | ASP.NET Core
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. AgaveJoe 30,126 Reputation points
    2022-10-11T14:08:01.757+00:00

    This is NOT a MVC or ASP.NET Core support question! Plus it is not possible for anyone on this forum to answer this question as we have no idea how your network is setup.

    Should we assume this is a home network and a router connects the web server to the internet? If so, the IP address and assigned by your ISP and can be found by logging into your router and looking. Port forwarding is a common way you direct traffic to a system on a home network. Read your router documentation.

    1 person found this answer helpful.
    0 comments No comments

  2. Bruce (SqlWork.com) 78,236 Reputation points Volunteer Moderator
    2022-10-11T15:42:21.977+00:00

    you first step is to buy a static ipaddress from your ISP. this is your external ipaddress.
    if required, convert your server from dynamic ipaddress to static ipaddress with you dhcp server (often a modem). this is your internal ipaddress.
    then as suggested enable port forwarding on the ISP modem/switch from the external ipaddress/port to the internal ipaddress/port.

    note: it may be cheaper to host in the cloud then to buy a static ipaddress

    1 person found this answer helpful.
    0 comments No comments

  3. Bruce (SqlWork.com) 78,236 Reputation points Volunteer Moderator
    2022-10-11T20:58:05.197+00:00

    first test the server firewalls are open. on a machine on the local network, access IIS by the server internal ipaddress and ports. you can use telnet to test the ports are open.

    then you need a client machine that is not on your local network, but has internet access.

    be sure to configure port forwarding on your ISP connection device to your internal server's ipaddress and desired ports. it may also have a firewall that need configuration.

    on the client machine update the hosts file to have domain name for the public static ip.

    test http access via the domain name.

    then generate a self signed cert for the domain name. install as the ssl cert for IIS. then hit the site with https: from your test client. you will need to trust the certificate. if you don't want to install a fake ssl, use telnet to test port access, or configure http for both ports in the IIS bindings (be sure to disable https redirect in the asp.net core app).

    now update the internet DNS cname for your domain name to point to th public ipaddress. the seller of the domain name should have a tool for this. may take a couple hours to propagate.

    delete the host file entry in the test machine and valid access by DNS name.

    now buy a ssl certificate and install on IIS and configure IIS https binding. now test the https access from the test machine.

    https://www.digicert.com/kb/csr-creation-ssl-installation-iis-10.htm

    note: whoever you buy the ssl cert from will have instructions.

    really, the only part the windows server (the server does not have any knowledge of its external ipaddress).

    1) configure internal static ipaddress instead of dhcp
    2) open the firewall ports
    3) install ssl certificate and https binding (hostname binding is optional)

    1 person found this answer helpful.

  4. Volk Volk 551 Reputation points
    2022-10-11T20:23:21.447+00:00

    I have a static IP and a separate computer for this. That's why I'm asking how to do this temporarily without direct DNS redirection to my static IP and without premature purchase of a real certificate.

    P.S. A separate server or cloud on the contrary is too expensive. ))
    Why would I do this with a stable fast Internet and a powerful machine?

    So do you have an example of how to do this for Net Core 6 as part of IIS on Windows Server 2022? In localhost on the server, the site works as it should on ports 82 and 434, but does not want to from the outside.


  5. Volk Volk 551 Reputation points
    2022-10-14T18:24:21.96+00:00

    I have found a solution. :)

    The local network does not play a role.
    No need to change hosts on external independent computers.

    !!! Need to open port 82 (because port 80 is occupied by the default site, and port 81 is occupied by another test site) !!!

    Just need to do this in IIS and enter the site at a static address and port:

    250613-good-0.png
    250567-good-1.png
    250558-good-2.png

    Now I calmly go to the site from the outside using such links:

    http://StaticIP:82
    https://StaticIP:443

    And when the site is ready, tested and filed in, you can buy a full-fledged certificate and attach it to IIS.

    Thank you all for your advices! The question is closed. :)


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.