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;
       }

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

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

Try DigitalOcean for free

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

Sign up

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.