使用docker安裝nginx後會生成兩個配置檔案分別是/etc/nginx/nginx.conf和/etc/nginx/conf.d/default.conf
此時如果需要配置反向**,需要修改default.conf檔案。
修改方式一:
修改方式二:
將上面兩個檔案在啟動容器命令中新增檔案掛載
如: docker run -itd -p 8800:80 --name test-nginx -v /root/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /root/nginx/conf/default.conf:/etc/nginx/conf.d/default.conf nginx
default.conf檔案內容:
server
location /test
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#error_page 500 502 503 504 /50x.html;
location = /50x.html
# proxy the php scripts to apache listening on 127.0.0.1:80
##location ~ \.php$
# pass the php scripts to fastcgi server listening on 127.0.0.1:9000
##location ~ \.php$
# deny access to .htaccess files, if apache's document root
# concurs with nginx's one
##location ~ /\.ht
}## 容器內網ip和nginx在同一網路,未配置埠對映,用nginx實現反向**+負載均衡。
docker安裝nginx並配置SSL
本文用於向已有網域名稱情況下用docker對nginx進行配置,包括不需要ssl證書的情況和需要使用ssl的情況 1.已安裝好docker環境 2.申請好網域名稱 3.ssl證書 可選 docker pull nginx建目錄用於存放nginx配置檔案 證書檔案 mkdir nginx conf.d...
Docker下Nginx安裝和配置
映象名 版本名 標籤 docker pull nginx 1.20.1 刪除對應的映象 docker rmi 映象名 版本號 映象id docker run options image command arg.docker run 設定項 映象名 映象啟動執行的命令 映象裡面預設有的,一般不會寫 d...
基於Docker安裝nginx以及配置https
https的證書 於阿里雲的ssl 2 建立掛載目錄 mkdir p opt nginx 4 編寫nginx.conf配置檔案,放在conf資料夾中 5 執行nginx docker run name nginx d p 443 443 v opt nginx conf nginx.conf etc...