鼎鼎知识库
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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

pirms 3 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ```
  2. sudo apt-get update
  3. sudo apt-get install apt-transport-https
  4. sudo apt-get update
  5. cd tmp
  6. wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
  7. sudo dpkg -i packages-microsoft-prod.deb
  8. sudo apt-get update
  9. sudo apt install dotnet-sdk-3.1
  10. ```
  11. ```
  12. sudo apt update
  13. sudo apt install nginx
  14. sudo systemctl status nginx
  15. ```
  16. ```
  17. sudo apt update
  18. sudo apt install nano
  19. nano demo2.txt
  20. ```
  21. ```
  22. cd /
  23. cd etc/nginx/sites-available
  24. nano default
  25. server {
  26. listen 80;
  27. server_name {api.your-domain-name.com};
  28. root /home/ubuntu/apps/{your-folder-name};
  29. location / {
  30. proxy_pass http://localhost:5000;
  31. proxy_http_version 1.1;
  32. proxy_set_header Upgrade $http_upgrade;
  33. proxy_set_header Connection keep-alive;
  34. proxy_set_header Host $host;
  35. proxy_cache_bypass $http_upgrade;
  36. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  37. proxy_set_header X-Forwarded-Proto $scheme;
  38. }
  39. }
  40. sudo service nginx restart
  41. cd /etc/systemd/system
  42. nano demo.service
  43. [Unit]
  44. Description=This is a sample application for my tutorial
  45. [Service]
  46. WorkingDirectory=/home/ubuntu/apps/sample
  47. ExecStart=/usr/bin/dotnet /home/ubuntu/apps/sample/Harrys.Sample.ddl
  48. Restart=always
  49. # Restart service after 10 seconds if the dotnet service crashes:
  50. RestartSec=10
  51. KillSignal=SIGINT
  52. SyslogIdentifier=dotnet-example
  53. User=www-data
  54. Environment=ASPNETCORE_ENVIRONMENT=Production
  55. Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
  56. # If you need to run multiple services on different ports set
  57. # the ports environment variable here:
  58. # Environment=ASPNETCORE_URLS=http://localhost:6000
  59. [Install]
  60. WantedBy=multi-user.target
  61. sudo systemctl enable demo.service
  62. sudo systemctl status demo.service
  63. ```
  64. > https://hbhhathorn.medium.com/install-an-asp-net-core-web-api-on-linux-ubuntu-18-04-and-host-with-nginx-and-ssl-2ed9df7371fb