1. 程式人生 > 其它 >harbor中nginx-photon升級nginx

harbor中nginx-photon升級nginx

1、進入容器檢視當前編譯安裝外掛

nginx -V

--prefix=/etc//nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log --add-module=../nginx-njs/njs-0.4.2/nginx --with-http_ssl_module \
--with-pcre --with-ipv6 --with-stream --with-http_auth_request_module --with-http_sub_module \
--with-http_stub_status_module --with-http_v2_module

 

2、下載njs模組

git地址:https://github.com/nginx/njs.git

yum -y install git

cd /usr/local/nginx-njs

git clone https://github.com/nginx/njs.git

 

 

3、在 本地編譯安裝nginx

#下載nginx原始碼包:
wget http://nginx.org/download/nginx-1.21.6.tar.gz
# 解壓
tar zxf nginx-1.21.6.tar.gz -C /usr/local/
# 編譯安裝
./configure --prefix=/etc//nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --add-module=../nginx-njs/njs/nginx --with-http_ssl_module --with-pcre --with-ipv6 --with-stream --with-http_auth_request_module --with-http_sub_module --with-http_stub_status_module --with-http_v2_module
make && make install
# 檢視安裝是否成功

[root@localhost nginx-photon]# nginx -V
nginx version: nginx/1.21.6
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc//nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --add-module=../nginx-njs/njs/nginx --with-http_ssl_module --with-pcre --with-ipv6 --with-stream --with-http_auth_request_module --with-http_sub_module --with-http_stub_status_module --with-http_v2_module
[root@localhost nginx-photon]# which nginx
/usr/sbin/nginx

 

 

4、準備查詢nginx1.21.6依賴庫並移動到Dockerfile所在資料夾中

find / -name libssl.so.1.1 exec cp {} /root/nginx-photon/ \;
find / -name libssl.so.10 exec cp {} /root/nginx-photon/ \;

find / -name libcrypto.so.10 exec cp {} /root/nginx-photon/ \;
cp /usr/sbin/nginx  /root/nginx-photon/

 

5、編輯Dockerfile

FROM goharbor/nginx-photon:v1.10.0
USER root
COPY nginx /usr/sbin/nginx
COPY libssl.so.10 /usr/lib64/libssl.so.10
COPY libcrypto.so.10 /usr/lib64/libcrypto.so.10
RUN chmod a+x /usr/sbin/nginx
RUN chown nginx:nginx /usr/sbin/nginx
USER nginx

 6、打包生成映象

docker build -t nginx-photon:zk01 .
docker save nginx-photon:zk01 > nginx-photon.tar

 

7、上傳至harbor伺服器所在機器後載入映象

docker load -i nginx-photon:zk01

 

8、修改docker-compose配置檔案中nginx-photon映象版本並重啟映象

docker-compose up