Linux Disibutaion:ubuntu 16.04.1 LTS
Web Server:nginx, Kestrel
about how to deploy ASP. NET core in Linux I'm not in the details here, so you can refer to ASP. Run on Linux (Ubuntu)
Here I need three VMS:
NGINXVM01: Doing a Load balancer server
NGINXVM02: Service Node 1
NGINXVM03: Service Node 2
Approximate service architectures such as:
Configure the Load Balancer node (NGINXVM01):
sudo apt-get install-y nginxsudo touch/etc/nginx/sites-available/nginxlb-proxysudo vi/etc/nginx/sites-available/ Nginxlb-proxy
Nginx site configuration files are in the/etc/nginx/sites-available directory.
The active Web site is in the/etc/nginx/sites-enabled directory.
Nginx configuration Files Reference configuration file Structure in the Nginx guide
Write the contents to the Nginxlb-proxy file:
Upstream nginxlb{ server nginxservice.cloudapp.net:8082; Server nginxservice.cloudapp.net:8083;} server { listen 8081 default_server; server_name nginxservice.cloudapp.net; Location/ { proxy_pass http://nginxlb; Proxy_set_header x-real-ip $remote _addr; Proxy_next_upstream Error timeout Invalid_header http_500 http_502 http_503; }
There are multiple modes for load balancing using Nginx, refer to official website using Nginx as HTTP load balancer
I have tested the various load modes of nginx.
Reboot loading Nginx configuration file
sudo nginx-tsudo nginx-s Reload
To this step, nginx default enabled sites are the defaults, we need to change the enabled site to Nginxlb-proxy
sudo ln-s/etc/nginx/sites-available/nginxlb-proxy/etc/nginx/sites-enabled/ #删除默认启用的站点defaultsudo rm/etc/ Nginx/sites-enabled/default
Service node ASP. NET Core Site deployment steps, refer to the previous blog.
Linux+asp.net Core+nginx Four-layer load balancing