nginx安装

wget https://nginx.org/download/nginx-1.14.0.tar.gz
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel



wget -c http://luajit.org/download/LuaJIT-2.0.5.tar.gz

tar xzvf LuaJIT-2.0.5.tar.gz

cd LuaJIT-2.0.5

make install PREFIX=/usr/local/luajit

export LUAJIT_LIB=/usr/local/luajit/lib

export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0



wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz

tar -xzvf v0.3.0.tar.gz



tar zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0

./configure \
--with-pcre \
--prefix=/data/qsc/nginx \ #制定nginx目录
--with-http_stub_status_module \#nginx 监控模块
--with-http_gzip_static_module \#提供预压缩的静态文件
--with-http_v2_module \#支持http2.0
--without-http_limit_req_module \#限定客户端创建连接的频率
--without-http_limit_conn_module \#通过配置参数限定客户端的最大并发连接数
--add-module=/usr/local/src/ngx_devel_kit-0.3.0 \
--add-module=/usr/local/src/lua-nginx-module-0.10.11 \#lua模块
--with-http_ssl_module #ssl模块

make 
make install

 cp /usr/local/luajit/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2

vim nginx.conf
user www;
worker_processes auto;
worker_cpu_affinity auto;
worker_rlimit_nofile 51200;
error_log /data/qsc/nginx/logs/error.log;
pid /var/run/nginx.pid;


events {
use epoll;
worker_connections 51200;
multi_accept on;
}


http {
include mime.types;
default_type application/octet-stream;

log_format json '{
"user_ip": "$http_x_real_ip",
"lan_ip": "$remote_addr",
"log_time": "$time_iso8601",
"user_req": "$request",
"http_code": "$status",
"body_bytes_sents": "$body_bytes_sent",
"req_time": "$request_time",
"user_ua": "$http_user_agent",
"http_referer": "$http_referer",
"http_x_forwarded_for": "$http_x_forwarded_for",
"request_time": "$request_time",
"upstream_response_time": "$upstream_response_time",
"upstream_connect_time": "$upstream_connect_time",
"upstream_header_time": "$upstream_header_time",
"cookie": "$http_cookie",
"request_body": "$request_body"
}';

sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
keepalive_timeout 120;
client_header_timeout 10m;
client_body_timeout 10m;
send_timeout 10m;
connection_pool_size 8192;
output_buffers 4 128k;
client_max_body_size 30m;
client_body_buffer_size 512k;
request_pool_size 8k;
server_names_hash_bucket_size 128; 

proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;

fastcgi_connect_timeout 600;
fastcgi_send_timeout 600;
fastcgi_read_timeout 600;
fastcgi_buffer_size 128k;
fastcgi_buffers 2 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;

gzip on;
gzip_http_version 1.1;
gzip_min_length 1k;
gzip_comp_level 5;
gzip_proxied any;
gzip_disable "msie6";
gzip_types text/plain application/x-javascript text/xml application/xml application/xml+rss text/javascript text/css application/javascript;
gzip_buffers 4 16k;
gzip_vary on;

include /data/nginx/conf/conf.d/*.conf;

}

vim /data/nginx/conf/conf/conf.d/api_gateway.conf
upstream api_gateway {
#server 10.47.160.85:8114; #api_gateway01
#server 10.47.53.204:8114; #api_gateway02
#server 10.47.49.243:8114; #api_gateway03
#server 10.28.15.220:8114; #api_gateway04
#server 10.47.52.157:8114; #api_gateway05
#server 10.46.68.126:8114; #api_gateway06
#server 10.47.54.215:8114; #api_gateway07
#server 10.47.52.254:8114; #api_gateway08
server 10.47.48.174:8114; #api_gateway09

check interval=3000 rise=2 fall=5 timeout=1000;
}

server {
listen 80;
server_name gateway.qschou.com;
location / {
proxy_next_upstream off ;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://api_gateway;


}
}
server {
listen 443;
server_name gateway.qschou.com;
access_log /data/qsc/nginx/logs/gateway.log json;
ssl on;
ssl_certificate /data/qsc/nginx/conf/cert/qschou.com.pem;
ssl_certificate_key /data/qsc/nginx/conf/cert/qschou.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
proxy_next_upstream off ;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://api_gateway;


}
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值