docker中部署nginx+cgi+https post服务
-
启动docker 容器
docker run -it -d --privileged --restart=always --name cgiPostServer -p 8000:443 ubuntu16.04:16.04 /sbin/init
–privateged 使container内的root拥有真正的root权限,不进行降权处理。
-p 做了端口映射,使得访问本机相应端口即可访问到虚拟机相应接口 -
建立终端交互
docker exec -it a3c7bc204d5b /bin/bash
同时 只能使用 docker exec -it systemctl5 /bin/bash 因为 exec 可以让我们执行被覆盖掉的默认命令 /bin/bash 同时 -it 也是必须的。
-
部署基础环境
apt-get update apt-get install systemd # 安装systemmd apt install vim apt-get install net-tools apt-get install wget apt-get install gcc automake autoconf libtool make
-
安装nginx
wget http://nginx.org/download/nginx-1.15.9.tar.gz ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-openssl=/usr/local/src/openssl-1.1.1g make make install systemctl status nginx # 检查nginx是否开启 curl 127.0.0.1:8080 #访问本地80端口
–prefix:Nginx安装部署后的根目录 默认为/usr/local/nginx目录。注意:这个目标的设置会影响其他参数中的相对目录。例如,如果设置了–sbin-path=sbin/nginx,那么实际上可执行文件会被放到/usr/local/nginx/sbin/nginx中
-
安装openssl
apt-get install perl cd /usr/src wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz --no-check-certificate tar zxvf openssl-1.1.1g.tar.gz cd openssl-1.1.1g/ ./config shared --prefix=/usr/local/ make install cp libcrypto.so.1.1 /usr/lib/x86_64-linux-gnu/ cp libssl.so.1.1 /usr/lib/x86_64-linux-gnu/ rm /usr/bin/openssl #删除原有的openssl相关文件 ln -s /usr/local/bin/openssl /usr/bin/openssl openssl version #设置软连接
# 生成服务端私钥 openssl genrsa -out server.key 2048 # 生成服务端公钥 openssl rs