Report this

What is the reason for this report?

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

Posted on April 29, 2018

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.



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!

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

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.

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.