【Azure 應用服務】App Service For Container 配置Nginx,設定/home/site/wwwroot/目錄為啟動目錄,并配置反向代理
【Azure 應用服務】App Service For Container 配置Nginx,設定/home/site/wwwroot/目錄為啟動目錄,并配置反向代理
問題描述
通過Docker Desktop for Linux,配置Nginx鏡像後,自定義nginx.conf檔案,修改啟動目錄和對 /out 路徑的反向代理到部落格園的博文位址 (https://www.cnblogs.com/lulight/p/15180884.html), 然後部署到Azure App Service中的整體實作方案。
【Azure 應用服務】App Service For Container 配置Nginx,設定/home/site/wwwroot/目錄為啟動目錄,并配置反向代理
操作步驟(共5步)
第 0 步:啟動本地 Docker Desktop,并拉取Nginx 鏡像
# 1. pull nginx image ... need docker for linux
docker pull nignx
注意:必須切換為 Linux Container,避免在拉去 Nginx 鏡像時候出現如下錯誤:
C:\Users\bu>docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
no matching manifest for windows/amd64 10.0.19043 in the manifest list entries
第一步:建立Dockerfile 檔案
FROM nginx
COPY appnginx.html /home/site/wwwroot/index.html
COPY . /home/site/wwwroot
COPY nginx.conf /etc/nginx/nginx.conf
RUN .
【Azure 應用服務】App Service For Container 配置Nginx,設定/home/site/wwwroot/目錄為啟動目錄,并配置反向代理
附錄:方案中的靜态頁面内容
appnginx.html
<html>
<body>
<h1>Hello docker + nginx from china azure app service /home/site/wwwroot/ !</h1>
<h2>Hello docker + nginx from china azure app service /home/site/wwwroot/ !</h2>
<h3>Hello docker + nginx from china azure app service /home/site/wwwroot/ !</h3>
<h4>Hello docker + nginx from china azure app service /home/site/wwwroot/ !</h4>
<h5>Hello docker + nginx from china azure app service /home/site/wwwroot/ !</h5>
<h6>Hello docker + nginx from china azure app service /home/site/wwwroot/ !</h6>
</body>
</html>