1. install asp.net core in https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x
2. upload your code to AWS linux
3.try to run your code : dotnet coreapi.dll
4.try to test the website whether work fine: wget htpp://localhost/api/user
5.set up start asp.net core command become service.
sudo vim /etc/systemd/system/kestrel-coreapi.service
Content:
[Unit]
Description=Example ASP .NET Web Application running on Ubuntu 16.04
[Service]
WorkingDirectory=/home/ubuntu/projects/coreapi
ExecStart=/usr/bin/dotnet /home/ubuntu/projects/coreapi/CoreAPI.dll
Restart=always
RestartSec=10
SyslogIdentifier=CoreAPIlog
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
other command:
sudo systemctl enable kestrel-coreapi.service
sudo systemctl start kestrel-coreapi.service
sudo systemctl status kestrel-coreapi.service
6. you can restart liunx , it will auto start the asp.net core , you can try wget command.
7. install nginx for reverse proxy
sudo apt-get install nginx
sudo vim /etc/nginx/sites-available/default
Content:
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;
}
}
If you want to add domain:
server {
listen 80;
server_name www.your_domain_name.com;
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;
}
}
7.Test ngnix:
sudo nginx -t
8.Restart it:
sudo nginx -s reload