DOCKER 建立 配置 執行 NGINX 環境(阿里雲伺服器)
阿新 • • 發佈:2018-11-08
1. 拉取nginx
#拉取nginx的最新穩定版
sudo docker pull nginx
2.Docker建立Nginx容器並執行
#1.對映埠 80:80 ===>443:443 埠
#2.配置資料儲存路徑 /opt/nginx/conf.d :/etc/nginx/conf.d
$docker run -d \
--name=nginx \
--restart always \
-p 80:80 -p 443:443 \
-v /opt/nginx/conf.d:/etc/nginx/conf.d \
nginx
3.配置NGINX的server資訊
## conf - $mkdir /opt/nginx/conf.d $ cd /opt/nginx/conf.d # 建立這個目錄來載入nginx配置資料夾 - $vim demo.auicyh.com.conf #建立檔案 加入下面的配置 檔案的名稱要和域名一致 ## server_name 要訪問的二級域名或者一級域名 ## proxy_pass 監聽伺服器的埠 ```conf server { listen 80; server_name demo.auicyh.com; client_max_body_size 100M; location / { proxy_pass http://XX.XX.XXX.XX:28080; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }
4.如果是阿里雲的伺服器需要在阿里雲後臺配置相應的埠