6

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).

3
  • 1
    You can set this up with IIS(&Kestrel) or WebListener, but Kestrel does not directly support port sharing. Commented Jun 1, 2016 at 21:10
  • 1
    Have the same issue, ended up using WebListener, works perfectly. Commented 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. Commented Apr 5, 2017 at 18:50

1 Answer 1

6

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.