Reverse .Net Core with Nginx in CentOS 7

I haven't gotten .Net Core for a long time, and then I suddenly found that the Hyper-V virtual machine that comes with Windows seems to be very useful

.Net Core used Jexus as the server before, and suddenly wanted to try it with Nginx

1. Install .Net Core SDK in CentOS 7

sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm

sudo yum update
sudo yum install libunwind libicu
sudo yum install dotnet-sdk-2.1.105

2. Create a new .NET Core project

dotnet new razor -o aspnetcoreapp
cd aspnetcoreapp
dotnet run

3. Install Nginx

// To add the CentOS 7 EPEL repository, open a terminal and use the following command: 
sudo yum install epel- release

// Now that the Nginx repository is installed on your server, install Nginx using the following yum command 
sudo yum install nginx

// Nginx will not start by itself. To run Nginx, enter 
sudo systemctl start nginx

// If you are running a firewall, run the following commands to allow HTTP and HTTPS communication 
sudo firewall-cmd --permanent --zone= public --add-service= http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

// If you want to enable Nginx at system startup. Please enter the following command 
sudo systemctl enable nginx

If you can see the welcome page of Nginx using IP access, it means that Nginx is installed successfully

4. Use Nginx proxy

// Find the Nginx installation configuration file
cd /etc/nginx/

// Edit the configuration file 
vi nginx.conf

// Find the server node under http
 // Modify server_name to Ip address or domain name eg:192.168.1.222
 // Modify location / {proxy_pass http://localhost :5000;}

// Save and exit Esc
:wq!

// Restart Nginx 
nginx -s reload

5. Access using 192.168.1.222

 

Of course, this is just to make the website run, and there are still many configurations that need to be explored. . .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325855910&siteId=291194637