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


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.

@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 …

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel