openresty安装:
1.下载openresty
wget https://openresty.org/download/openresty-1.15.8.3.tar.gz
2.安装依赖包
yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
3.编译openresty
./configure --with-http_ssl_module --with-http_iconv_module --prefix=/home/app/openresty
make && make install
4.配置conf
cd /home/app/openresty/nginx/conf
vi nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
types_hash_max_size 2048;
include /home/app/openresty/nginx/conf/vhosts/*.conf;
#gzip on;
}
mkdir vhosts
cd vhosts
vi xxx_admin.conf
upstream gateway {
server xx.xx.xx.xxx:80xx;
}
server {
listen 8088;
server_name client.bbbbbb.com;
access_log logs/client.access.log main;
error_log logs/client.error.log crit;
location / {
root html;
# index index.html index.htm;
}
location ^~/api {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http://gateway;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
5.启动nginx
cd /home/app/openresty/nginx/sbin
./nginx