[Openresty] centos7.7 installation openresty

0, Background and Introduction Gateway
1.1 Background
OpenResty® Nginx is based on Lua and high-performance Web platform that integrates a large number of well-Lua libraries, as well as most third-party module dependencies. Used to easily set up to handle ultra-high concurrency, highly scalable dynamic Web applications, Web services and dynamic gateway. From official website

1.2 API gateway function
API gateway is inside a service system a plurality of micro-encapsulation services, provide external access to the only entry in the system to achieve high cohesion, loose coupling between system interaction effect achieved by the gateway. It can and Eureka, Ribbon, Hystrix and other components used in conjunction to achieve authentication and security, review and monitoring, dynamic routing, stress testing, load balancing, flow control and other functions
need to have the following features:

  • Unified access entry
  • Security: blacklist, authentication authority
  • Limiting: implement micro-computing service traffic flow is calculated based on the analysis of current limiting, you can define a variety of limiting rules.
  • Cache: data cache
  • Log: Logging
  • Monitor: recording request response data, time-consuming analysis of API, the performance monitoring
  • Retry: Retry abnormal
  • Fuse: Downgrade

1, the installation

yum -y install readline-devel pcre pcre-devel openssl openssl-devel gcc curl GeoIP-devel
wget https://openresty.org/download/openresty-1.13.6.2.tar.gz
./configure --with-luajit --with-pcre --with-http_gzip_static_module --with-http_realip_module --with-http_geoip_module --with-http_ssl_module --with-http_stub_status_module
make
make install

-With-http_gzip_static_module # static file compression
-with-http_stub_status_module # nginx monitoring state
-with-http_realip_module # can change the client request header in client IP address value (X-Real-IP and X-Forwarded-For), back-end server records original client IP address
-with-pcre # set PCRE library (PCRE PCRE-devel)
the -with-http_ssl_module # module using the https protocol. (OpenSSL OpenSSL-devel)
the -with-http_geoip_module # ip increased to obtain city information, such as latitude and longitude module (GeoIP-devel) according to

2, directory

cd /usr/local/openresty
ll
bin # 
COPYRIGHT
luajit
lualib
nginx # nginx目录,启动nginx
pod
resty.index
site

nginx operation, installation , advanced configuration (hot upgrade and split logs) , HTTP profile
luajit using C language code written in Lua interpreter ---- just in time instant resolve
lualib edited lua library

3, configuration
3.0 Firewall settings

firewall-cmd --zone=public --add-port=80/tcp --permanent
# –zone #作用域
# –add-port=80/tcp #添加端口,格式为:端口/通讯协议
# –permanent #永久生效,没有此参数重启后失效
systemctl stop firewalld.service  
systemctl start firewalld.service 

3.1 modify the configuration file

vi /etc/profile
  export NGINX_HOME=/usr/local/openresty/nginx
  export PATH=$PATH:$NGINX_HOME/sbin
source /etc/profile

4, modify the configuration file openresty

# 在server模块加上
vi nginx.conf
location /helloworld {
	default_type text/html;
    content_by_lua 'ngx.say("hello world")';
}
/usr/local/openresty/nginx/sbin/nginx -t -c /usr/local/openresty/nginx/conf/nginx.conf # 检查配置文件
./nginx -s reload # 重新启动nginx

Access http://192.168.35.110/helloworld output hello world

9, stress tests

yum -y install httpd-tools
ab -c10 -n50000 http://localhost:8080/ # -c:每次并发数为10个 -n:共发送50000个请求
He published 192 original articles · won praise 18 · views 80000 +

Guess you like

Origin blog.csdn.net/luolinll1212/article/details/103879311