I want to be able to run two applications using the same port on the same server. My challenge is both applications have a host file that contains the URL it's listening for on port 80. Usually a web server has the ability to create virtual hosts, but I have no idea what I should be doing in this situation (except googling for a solution).
-
1You can set this up with IIS(&Kestrel) or WebListener, but Kestrel does not directly support port sharing.Tratcher– Tratcher2016-06-01 21:10:12 +00:00Commented Jun 1, 2016 at 21:10
-
1Have the same issue, ended up using WebListener, works perfectly.pfedotovsky– pfedotovsky2016-06-24 19:45:09 +00:00Commented Jun 24, 2016 at 19:45
-
@pfedotovsky could you provide some details on your WebListener setup? I'm trying to forward localhost:8000 to two self hosted .NET Core 1.1 WebAPI services at localhost:8001/api/one and locahost:8002/api/two, but I'm not quite getting it.Xorcist– Xorcist2017-04-05 18:50:40 +00:00Commented Apr 5, 2017 at 18:50
Add a comment
|
1 Answer
In a production environment you typically want to use a reverse proxy to forward requests to your sites running on Kestrel. You set up your ASP.NET Core applications to run on different ports, i.e. http://example.com:5000 and http://example.com:5001. Then you use IIS, Apache, nginx or similar to act as a reverse proxy. The reverse proxy is listening on port 80 and is forwarding the incoming requests to your Kestrel instances.
Example:
http://example.com/app1 --> http://example.com:5000
http://example.com/app2 --> http://example.com:5001