nginx 反向代理 on ubuntu
安裝nginx
1 sudo apt-get install nginx
2 sudo service nginx start
如果沒有錯 繼續
修改配置文件
修改/etc/nginx/sites-available/default 的文件
sudo nano /etc/nginx/sites-available/default
註釋所有內容 Server{
#內容
}
這時會刷新 會出現502錯誤
然後 sudo nano /etc/nginx/conf.d/<任意名字>.conf文件
寫入配置
server {
listen 80;
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 $http_host;
proxy_cache_bypass $http_upgrade;
}
}
3 重啟nginx sudo nginx -s reload
PS:配置自動啟動 dotnet aaa.dll,相當於 windows 的“服務”
參考文檔https://docs.microsoft.com/en-us/aspnet/core/publishing/linuxproduction#configure-a-reverse-proxy-server
大功告成 ok
nginx 反向代理 on ubuntu