Question

How do I run more than one asp.net core application on Nginx server

I want to run two or more asp.net core applications on the same server. But the ip and port they use are 127.0.0.1:5000.


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

I found a solition ,

asp.net configration;

public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }

        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                 .UseUrls("http://localhost:5001/")    // We are here to work at a different port
                .Build();
    }

nginx configration

server_name  yourdomain.com ;
location / {

                proxy_pass http://localhost:5001; // Listening 5001 Port
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection keep-alive;
                proxy_set_header Host $http_host;
                proxy_cache_bypass $http_upgrade;

               # First attempt to serve request as file, then
               # as directory, then fall back to displaying a 404.
               # try_files $uri $uri/ =404;
       }

For each application you need to do broadcasting and listening through separate ports.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@mrkemaltas - Please do i need here to use supervisor to make each site always running ? or just set different port for each app in the program.cs file and set in nginx conf file ? if yes can you please provide me sample example of conf files ?

thanks a lot …