首页 > 系统相关 >透视HTTP协议课程实验环境配置(基于阿里云服务器Ubuntu)

透视HTTP协议课程实验环境配置(基于阿里云服务器Ubuntu)

时间:2023-01-14 11:04:48浏览次数:68  
标签:HTTP .. -- module nginx add openresty Ubuntu 服务器



tags: Ubuntu Network

写在前面

最近看看罗剑锋老师的​​透视HTTP协议​​, 折腾一下实验环境.

本来是想用mac(arm)来做的, 无奈Openresty的一个lua扩展不给力, 本地编译之后依然不行(表现为服务器错误), 所以就只能借助Intel了, 当然老师也提供了一种思路: 借助dockerfile构建基于arm的镜像实验环境(实在是因为我电脑内存不行, 不然高低折腾一下).


那么下面就开始在阿里云服务器(Ubuntu x86_64)上构建实验环境了.

主要用到的就是:

Openresty (安装起来比较麻烦, 需要源码编译)
telnet (apt安装即可)
Firefox(或者chromium, Chrome, edge) apt安装
wireshark (apt安装, 但是打不开, 可能是远程的原因)

准备工作

用于源码构建Openresty:

sudo apt-get install libpcre3-dev \
libssl-dev perl make build-essential curl

安装Firefox和wireshark​​1​​:

sudo apt install firefox

sudo add-apt-repository ppa:wireshark-dev/stable
sudo apt update
sudo apt install wireshark

安装Openresty

这个算是老大难问题, 放在最后. 参考了​​2​​,官方的源码构建方法, 这里我比较推荐源码安装, 顺便学一下项目构建方法了.

构建的配置参数部分, 参考​​3​​.

This module is not built by default, it should be enabled with the ​​--with-http_v2_module​​ configuration parameter.

wget https://openresty.org/download/openresty-1.21.4.1.tar.gz
tar -xvf openresty-1.21.4.1.tar.gz
cd openresty-1.21.4.1/
# 配置信息, 后面的参数一定要加, 不然之后会报错
./configure -j2 --with-http_v2_module
# 编译和链接
make -j2
# 安装
sudo make install

添加环境变量:

vi ~/.bashrc

# 添加:
export PATH=/usr/local/openresty/bin:/usr/local/openresty/nginx/sbin:$PATH

# 然后
source ~/.bashrc

查看版本:

$ resty -V
resty 0.28
nginx version: openresty/1.21.4.1
built by gcc 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
built with OpenSSL 1.1.1f 31 Mar 2020
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.33 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.21 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.9 --add-module=../rds-json-nginx-module-0.15 --add-module=../rds-csv-nginx-module-0.09 --add-module=../ngx_stream_lua-0.0.11 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --with-http_v2_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_ssl_module

测试

~/code/http_study/www$ ./run.sh start
~/code/http_study/www$ ./run.sh list
root 125555 1 0 Jan10 ? 00:00:00 nginx: master process /usr/local/openresty/bin/openresty -c conf/nginx.conf -p /home/zorch/code/http_study/www
nobody 125556 125555 0 Jan10 ? 00:00:00 nginx: worker process
nobody 125557 125555 0 Jan10 ? 00:00:00 nginx: cache manager process

完美, 接下来是telnet测试:

在这之前先添加一下​​hosts​​, 使用:

sudo vi /etc/hosts

#添加:
127.0.0.1 www.chrono.com
127.0.0.1 www.metroid.net
127.0.0.1 origin.io

然后就可以测试了:

~/code/http_study/www$ telnet www.chrono.com 80
Trying 127.0.0.1...
Connected to www.chrono.com.
Escape character is '^]'.
GET /10-1 HTTP/1.1
Host: www.chrono.com

HTTP/1.1 200 OK
Server: openresty/1.21.4.1
Date: Wed, 11 Jan 2023 10:49:39 GMT
Content-Type: text/plain
Connection: keep-alive
content-length: 19

10-1 GET&HEAD test

完美~

ref


  1. ​How to Install and Use Wireshark on Ubuntu Linux? - GeeksforGeeks​​; ↩︎
  2. ​OpenResty - Installation​​; ↩︎
  3. ​Module ngx_http_v2_module (nginx.org)​​; ↩︎


标签:HTTP,..,--,module,nginx,add,openresty,Ubuntu,服务器
From: https://blog.51cto.com/u_15366127/6007532

相关文章

  • ubuntu解压.rar文件
    1.在终端中输入命令安装压缩程序rar和解压缩的unrar.sudoapt-getinstallrarunrarsudoapt-getinstallrarrar 2.linux中解压rar类型文件的命令为:unrarefi......
  • http 请求头 content-type 字段值
    Content-type定义了http请求的数据类型。如果设置在请求头中,则定义的是请求体的数据类型;如果设置在响应头中,则定义的是响应体的数据类型;请求头--Request-Headers:一般......
  • IDEA配置网络代理Socks/HTTP
    前言内网限制导致idea不能联网解决打开设置→HTTPProxy点击Manualproxyconfiguration(手动代理配置)是什么类型网络就选择什么apply就行了检查可以下载插件即为成功代......
  • HttpClient服务器调用发送接收参数对比介绍
    前言:一直使用HttpClient做服务器调用但是老是接收参数有问题,今天把它的常见的方法,用CRUD写了一遍希望对你有用1.POST©sendpostForEntity(url,request就是需要保存的对......
  • 【论文导读】- SpreadGNN: Serverless Multi-task Federated Learning for Graph Neur
    文章目录​​论文信息​​​​摘要​​​​SpreadGNNFramework​​​​用于图层次学习的联邦图神经网络​​​​图神经网络的联邦多任务学习​​​​SpreadGNN​​​​DPA-......
  • OKHttpUtil搞定Http请求
    一、OKHttpUtil功能根据URL自动判断是请求HTTP还是HTTPS,不需要单独写多余的代码。默认情况下Cookie自动记录,比如可以实现模拟登录,即第一次访问登录URL后后续请求就是登......
  • 直播服务器搭建
    Nginx安装流媒体 yuminstallgcc-c++ -yyuminstall-ypcrepcre-develyuminstall-yzlibzlib-develyuminstall-yopensslopenssl-devel wgethttps://......
  • 基于 MongoDB 及 Spring Boot 的文件服务器的实现
    MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的,旨在为WEB应用提供可扩展的高性能数据存储解决方案。它支持的数据......
  • 原生GIT版本服务器配置和测试
    前言:原生GIT版本服务器指使用Linux内核自带的GIT软件来构建版本服务器,而不采用Git-lab、SCM-Manager等非Linux原生系统。本文提供原生GIT安装、配置、测试和安全性设置。以......
  • Ubuntu Server20.04 sssd+samba4共享无法访问问题解决
    UbuntuServer20.04sssd+samba4共享无法访问问题解决报错: \\ipisnotaccessible排查:在samba的log里(/var/log/samba/log.ip)能看到winbinddnotrunning解决:#apt-getins......