鼎鼎知识库
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

2021.4.18使用Nginx部署网站.md 1.9KB

sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
cd tmp
wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt install dotnet-sdk-3.1
sudo apt update
sudo apt install nginx
sudo systemctl status nginx
sudo apt update
sudo apt install nano
nano demo2.txt
cd /
cd etc/nginx/sites-available
nano default

server {
    listen        80;
    server_name   {api.your-domain-name.com};
    root /home/ubuntu/apps/{your-folder-name};
    location / {
        proxy_pass         http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

sudo service nginx restart
cd /etc/systemd/system
nano demo.service

[Unit]
Description=This is a sample application for my tutorial
[Service]
WorkingDirectory=/home/ubuntu/apps/sample
ExecStart=/usr/bin/dotnet /home/ubuntu/apps/sample/Harrys.Sample.ddl
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
# If you need to run multiple services on different ports set
# the ports environment variable here:
# Environment=ASPNETCORE_URLS=http://localhost:6000
[Install]
WantedBy=multi-user.target


sudo systemctl enable demo.service
sudo systemctl status demo.service

https://hbhhathorn.medium.com/install-an-asp-net-core-web-api-on-linux-ubuntu-18-04-and-host-with-nginx-and-ssl-2ed9df7371fb