apisix/conf/nginx.conf
2019-05-17 15:58:15 +08:00

100 lines
2.4 KiB
Nginx Configuration File

master_process on;
worker_processes 1;
worker_cpu_affinity auto;
user resty;
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;;';
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;
upstream backend {
server 0.0.0.1;
balancer_by_lua_block {
apisix.balancer_phase()
}
}
init_by_lua_block {
require "resty.core"
apisix = require("apisix")
apisix.init()
}
init_worker_by_lua_block {
apisix.init_worker()
}
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()
}
access_by_lua_block {
apisix.access_phase()
}
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;
header_filter_by_lua_block {
apisix.header_filter_phase()
}
log_by_lua_block {
apisix.log_phase()
}
}
}
}