Skip to main content
Version: 2.4

自定义 Nginx 配置

APISIX 会通过 apisix/ngx_tpl.lua 这个模板和 conf/config-default.yamlconf/config.yaml 的配置生成 Nginx 配置文件。

在执行完 ./bin/apisix start,你可以在 conf/nginx.conf 看到生成的 Nginx 配置文件。

在自定义 Nginx 配置文件之前,烦请仔细阅读 conf/config-default.yaml。你可以在 conf/config.yaml 里面覆盖掉默认值。举个例子,你可以通过 xxx_snippet 之类的配置,在 conf/nginx.conf 里面注入你的自定义配置:

...# config.yaml 里面的内容nginx_config:    main_configuration_snippet: |        daemon on;    http_configuration_snippet: |        server        {            listen 45651;            server_name _;            access_log off;
            location /ysec_status {                req_status_show;                allow 127.0.0.1;                deny all;            }        }
        chunked_transfer_encoding on;
    http_server_configuration_snippet: |        set $my "var";    http_admin_configuration_snippet: |        log_format admin "$request_time $pipe";    http_end_configuration_snippet: |        server_names_hash_bucket_size 128;    stream_configuration_snippet: |        tcp_nodelay off;...