1

I have a web server on my lan and I want to expose it to the internet. Since I only have one public ip address, my question is: when tcp/ip request comes to my router via dns, how my router will know which site to choose as a destination?

e.g 1st site is http://sitenumberone.net and 2nd http://sitenumbertwo.net

since both will have the same dns resolution(the same public ip) I am trying to understand how can i filter the trafic on my router and to direct the data to the proper site. i am confused since both use port 80.

thanks

Marco
  • 23
  • 7

1 Answers1

-1

Welcome to Server Fault.

You are looking for a reverse proxy.

@Gerald Schneider made an excellent tutorial about setting up a reverse proxy with nginx or Apache, but if you want to do it with IIS (which is not a great idea since IIS is really slow for those things), you can have a look here.

EDIT: after reading what you exactly wanted (I completely messed up, I'm sorry for this), you don't have to use a reverse proxy. You'll use a reverse proxy if you multiple Web servers with multiple domains pointing to public port 80 and/or 443.

You can simply have 2 vHosts, one responding to https://sitenumberone.net and the second one responding to https://sitenumbertwo.net, that's it.

LeRouteur
  • 376
  • 2
  • 13
  • Thank you. Just one more question. If I want to change ports in bindings on site settings, can I use whatever port I want to distinguish my sites. Like, first site http://192.169.11.12:6060 and second http://10.269.11.12:7070 if I want to access on my local lan. is this okay? thanks a lot – Marco Oct 05 '20 at 10:54
  • Well, it's up to you: you should check if the port you want to configure for your site will conflict with an app already running on that port. But basically, yes it's possible. Btw consider accepting my answer if it helped you (tick the green checkbox) :) – LeRouteur Oct 05 '20 at 11:57
  • There is no need for a reverse proxy as both sites are on the same server. Simple standard port forwarding is good enough. – TomTom Oct 05 '20 at 13:59
  • @TimTom Thanks. and what if they were on different web servers? If I set port forwarding: one server will listen on port 80 and another one on 8080. Reverse proxy would make sense here? – Marco Oct 05 '20 at 14:34
  • " and what if they were on different web servers?" - then you ask a question that does not say "they are on the same web server". – TomTom Oct 05 '20 at 19:29
  • @TomTom I understood that there was 2 Web servers responding to 2 differents domain names. In this case, using a reverse proxy is useful. – LeRouteur Oct 06 '20 at 06:01
  • Btw having port forwarding is really... ugly. Imagine you have to type "https://sitenumber1.com:81". Only for 1 site, it's ok, but if it's for all the websites you browse during the day... that's annoying. – LeRouteur Oct 06 '20 at 06:07
  • OTOH a router is not a reverse proxy. What I generally would do is port forwarding 80 and 443 to an internal reverse proxy. That said, it is unusual to run a large number of websites and not have IP addresses (as in: plural) available. – TomTom Oct 06 '20 at 07:30
  • @TomTom why being that aggressive? Do you have something to compensate by being like that with other people? We are talking about this case right now, don't bring older problems on the table. And yes, I'm sorry, I messed up. That's my fault. But don't be that aggressive dude, that's just annoying and won't bring you anything. – LeRouteur Oct 06 '20 at 07:41
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/113781/discussion-between-lerouteur-and-tomtom). – LeRouteur Oct 06 '20 at 10:16