apisix/conf/nginx.conf

103 lines
2.5 KiB
Nginx Configuration File
Raw Normal View History

2019-04-10 11:08:25 +08:00
master_process on;
worker_processes 1;
worker_cpu_affinity auto;
error_log logs/error.log warn;
pid logs/nginx.pid;
worker_rlimit_nofile 20480;
events {
accept_mutex off;
worker_connections 10620;
}
worker_shutdown_timeout 1;
http {
lua_package_path "/usr/share/lua/5.1/?.lua;$prefix/lua/?.lua;;";
lua_package_cpath '/usr/lib64/lua/5.1/?.so;;';
2019-04-10 11:08:25 +08:00
lua_shared_dict plugin-limit-req 10m;
lua_shared_dict plugin-limit-count 10m;
lua_shared_dict prometheus_metrics 10m;
2019-04-10 11:08:25 +08:00
lua_ssl_verify_depth 5;
ssl_session_timeout 86400;
lua_socket_log_errors off;
resolver ipv6=off local=on;
resolver_timeout 5;
lua_http10_buffering off;
log_format main '$remote_addr - $remote_user [$time_local] $http_host "$request" $status $body_bytes_sent $request_time "$http_referer" "$http_user_agent" $upstream_addr $upstream_status $upstream_response_time';
access_log logs/access.log main buffer=32768 flush=3;
open_file_cache max=1000 inactive=60;
client_max_body_size 0;
server_tokens off;
more_set_headers 'Server: APISIX web server';
2019-04-10 11:08:25 +08:00
upstream backend {
server 0.0.0.1;
balancer_by_lua_block {
apisix.balancer_phase()
}
}
2019-04-10 11:08:25 +08:00
init_by_lua_block {
require "resty.core"
apisix = require("apisix")
apisix.init()
2019-04-10 11:08:25 +08:00
}
init_worker_by_lua_block {
apisix.init_worker()
2019-04-10 11:08:25 +08:00
}
server {
listen 9080;
include mime.types;
location / {
set $upstream_scheme 'http';
set $upstream_host $host;
set $upstream_upgrade '';
set $upstream_connection '';
set $upstream_uri '';
rewrite_by_lua_block {
apisix.rewrite_phase()
}
2019-04-10 11:08:25 +08:00
access_by_lua_block {
apisix.access_phase()
2019-04-10 11:08:25 +08:00
}
proxy_http_version 1.1;
proxy_set_header Host $upstream_host;
proxy_set_header Upgrade $upstream_upgrade;
proxy_set_header Connection $upstream_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass_header Server;
proxy_pass_header Date;
proxy_pass $upstream_scheme://backend$upstream_uri;
2019-04-10 11:08:25 +08:00
header_filter_by_lua_block {
apisix.header_filter_phase()
2019-04-10 11:08:25 +08:00
}
log_by_lua_block {
apisix.log_phase()
2019-04-10 11:08:25 +08:00
}
}
}
}