首先我们先部署Openresty服务,事实上就是继承了安全组件的nginx服务。
image.png

一、安装Openresty服务

  1. rz -E 上传openresty的源码包, 接下来进行编译源码包
  2. yum -y install gcc make yum -y install pcre pcre-devel zlib zlib-devel openssl-devel readline-devel | 安装相关插件服务
  3. tar -xvf openresty-1.15.8.3.tar.gz | 进行解压openrestry的操作
  4. ./configure --prefix=/usr/local/openresty --with-http_stub_status_module --with-http_ssl_module --with-stream && make -j 5 && make install | 进行编译操作 --with stream 调用stream模块 实现四层负载均衡。
  5. 配置环境变量vi + /etc/profile,加入PATH=$PATH:/usr/local/openrestry/nginx/sbin :wq之后,执行source /etc/profile
  6. 启动openrestry服务 /usr/local/openresty/nginx/sbin
  7. 调整nginx的服务参数

(2) yum -y install gcc make yum -y install pcre pcre-devel zlib zlib-devel openssl-devel readline-devel | 其实也就readline -devel插件未安装。
image.png

(4) ./configure —prefix=/usr/local/openresty —with-http_stub_status_module —with-http_ssl_module —with-stream && make -j 5 && make install | 编译 并进行相应模块调用。
image.png
(5)配置环境变量vi + /etc/profile,加入PATH=$PATH:/usr/local/openrestry/nginx/sbin :wq之后,执行source /etc/profile.
(6)cd /usr/local/openresty/nginx/sbin
image.png
查看是否正常启动了openrestry服务
image.png
(7)将nginx放入到systemctl进行管理
py3) [root@zhangsir system]# cd /usr/lib/systemd/system | 切入到 system目录下
(py3) [root@zhangsir system]# cp vdo.service nginx.service | 复制一个文件,变成nginx的文件
(py3) [root@zhangsir system]# vim nginx.service | 编辑文件然后将下列信息放入到文件中

  1. [Unit]
  2. Description=nginx
  3. After=network.target | 网络服务器启动后,在启动nginx服务
  4. [Service]
  5. Type=forking
  6. #RemainAfterExit=yes
  7. ExecStart=/usr/local/openresty/nginx/sbin/nginx
  8. ExecStop=/usr/local/openresty/nginx/sbin/nginx
  9. [Install]
  10. WantedBy=multi-user.target

image.png

  1. #nginx服务的操作
  2. nginx -t 查看nginx的语法
  3. nginx -s stop 基于nginx 关闭nginx
  4. nginx 基于nginx 启动
  5. nginx -v 查看版本
  6. nginx -V 查看编译之前配置信息

接下来调整nginx.conf的参数
在配置nginx.conf里面写入
proxy_pass http://localhost:8080; | 开启反向代理参数 代理到jumpserver中。

  1. server {
  2. listen 80;
  3. server_name localhost;
  4. location / {
  5. root html;
  6. index index.html index.htm;
  7. proxy_pass http://localhost:8080;
  8. }
  9. error_page 500 502 503 504 /50x.html;
  10. location = /50x.html {
  11. root html;

#Openresty安装ca证书服务

首先我们先找到证书的目录位置
[root@zhangsir ~]# cd /usr/local/src/ctf/
image.png
在nginx.conf配置文件中放入CA证书。

  1. # HTTPS server
  2. server {
  3. listen 443 ssl;
  4. server_name localhost;
  5. ssl_certificate /usr/local/src/ctf/upwen.crt;
  6. ssl_certificate_key /usr/local/src/ctf/upwen.key;
  7. location / {
  8. root html;
  9. index index.html index.htm;
  10. # proxy_pass http://localhost:443
  11. }
  12. }
  13. }

image.png
[root@zhangsir sbin]# lsof -i:443
image.png
访问web网页测试: https://192.168.96.137https://192.168.96.137
image.png