0

I have a Windows Server which has my dev website on it and can be accessed via IP or server name http://servername on the actual server or http://servername.org.com on my home PC which is connecting to the same network via VPN.

I've created an additional site on my IIS test1 which uses the same port as my default. Unassigned IP address and with the host name test1.com. Within my hosts file, I have also added:

127.0.0.1 test1.com

On my actual server which I connect to via RDP, I can access this second website via the the URL of test1.com on a web browser and it works fine but when I do the same on my home PC, it does not work even though I'm connected to the same network via VPN. I've tried out different combinations of the URL such as http://servername.org.com./test1.com to no avail.

What would I need to do to accomplish this? Also, just a tag on question to this. Say my default website is version 1 of that website and I want to create version 2. What would be the best approach to managing this on my server?

  1. http://servername.org.com/v1/index.html for version 1 and the same for v2 but different directory.
  2. Or create a new website on my IIS per iteration so http://servername-v1.org.com and http://servername-v2.org.com

Or does it not really matter? Those different versions would just be dev versions. I currently do it the number 1 way but wondered if there was an actual proper way of doing this.

2
  • I am not 100% clear of your question. I assume you have an http proxy which dispatches your http request by looking at the target hostname? In that case, you need to access that new server named test1.com by editing your home PC's host file so test1.com maps to the same IP as servername.
    – some user
    Commented Mar 29, 2021 at 18:17
  • I also have difficulty with test1.com. Could you add some screenshots of your IIS setup?
    – harrymc
    Commented Mar 29, 2021 at 19:14

2 Answers 2

1
+50

If i Understand you correctly:

Windows development server located at servername.org.com:80 you created a second website on that windows development server and added to the windows development server hosts file 127.0.0.1 test1.com

when you are connected to that server and go to test1.com in that servers browser, it sees from it's hosts file that test1.com is at 127.0.0.1 which is local (i.e. the server you are on) and you are successful

when you are on your home pc, which does not have a hosts file entry for test1.com, it does not work

This is expected

you need to have an actual DNS entry for test1.com that points to servername.org.com's IP address, or a hosts file entry on your pc that has an entry

$servername.org.comsIPaddress test1.com

Without either of these, this will not work, becuase your browser cannot resolve test1.com.

Even though your computer is on the same virtual network, it has no awareness of where test1.com is located.

If you want to have multiple versions of the same website hosted at the same time, it might be easiest to create them on different ports, or to store the configurations in GIT or some other repository. there's so many ways to do it, it really depends on what you want to do.

2
  • 1
    Thanks! You pointed me in the direction that I wanted. I appreciate it. I will be adding an answer as well to fully flesh out what I did.
    – J.Do
    Commented Mar 31, 2021 at 10:53
  • awesome. glad to help. Commented Mar 31, 2021 at 20:44
0

As Timmy Browne directed, this is what I ended up doing.

My setup is that I use a VPN on my home PC and when connected. I remote desktop onto my web server where I can do stuff on it. I wouldn't be able to remote in if I wasn't connected to the VPN. Essentially on the same network.

On my IIS, I had "Default Web Site" which I could access on a browser on the web server as localhost or via IP or server name. This takes me to the IIS splash page, as expected. If I did this on my own PC but while still connected to the VPN, I clearly cannot use localhost as it's different on my home PC even though I am connected to the VPN. So if I wanted to get to the same IIS splash page on my home PC then I would need to enter servername.org.com or I could also use the IP of the server.

On my IIS, I created an additional website called "test". On my bindings for this website, I had it ported at 8080. This meant that if I used localhost:8080 or IP:8080 or hostname:8080 on a browser on the web server. This takes me to the splash page of the "test" website. Now if I did the same thing on my home PC I would need to specify the port to get the "test" website splash page, i.e. servername.org.com:8080 or IP:8080, otherwise it would just direct me to an existing live website called test.com that has nothing to do with my web server. However, I did not want to use servername.org.com:8080 for accessing my test website. I wanted to access it via test.com. This is where I altered my web server's host file and added:

127.0.0.1 test.com

So now, on a browser on the web server I could access the "test" website via test.com but if I really wanted to, I can still access it as localhost:8080 or IP:8080 but I rather use test.com. But I was to access test.com on my own PC while still connected to the VPN, it does not work. But as Timmy brought up, this is expected and from his answer, I ended up altering my own PC's host file to include this:

IPofServer test.com

Now if I tried to access test.com on my PC, it now takes me to the IIS splash page but this isn't what I wanted, I wanted it to take me to the "test" website splash page. But I did try test.com:8080 which took me to the page I wanted but I still did not want to include the port in the URL so I altered my own PC's host file to include a port like so:

IPofServer:8080 test.com

But what I found out that this doesn't work like that and the hosts file does not support ports. So if I actually tried going to test.com again on my own PC, it takes me to a live test.com website that has nothing to do with my web server. So what I ended up doing was using ngrok to essentially generate a URL that I could use that points to test.com:8080 by running it like this:

ngrok http http://test.com:8080

This generates a URL that I can use which points to the page test.com:8080 splash page.

UPDATE

I've realised at this point that since I am now using ngrok, I don't even need to alter my own PC's host file. I ideally wanted to use my own URL like test.com but this might not be doable but since ngrok generates a URL, I can just use:

ngrok http http://servername.org.com:8080

Which essentially works the same. ngrok does have a paid plan where I could use a subdomain but the free option is best for me at this moment.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .