【问题标题】:How to read text from another file in nginx.conf file?如何从 nginx.conf 文件中的另一个文件中读取文本?
【发布时间】:2022-01-14 06:38:26
【问题描述】:

我有一个nginx 配置文件。我不想在其中输入大量带有城市列表和GeoIp 禁止访问的文本,因此我决定将其放在单独的文件中。如何从配置文件中的另一个文件中读取。

我想从另一个文件中读取并插入这里的地方(nginx.conf):

http {

    access_log  /var/log/nginx/access.log   combined;
    error_log   /var/log/nginx/warn.log     warn;

    server_tokens off;

    upstream thumbor {
        server localhost:8888;
    }

    ...

我放在一个单独的文件中并希望在配置文件的 http 块中使用:

geoip_country /usr/share/GeoIP/GeoIP.dat;
       map $geoip_country_code $allowed_country {
           default no;
        AF no;
        AG no;

        ...
       }

【问题讨论】:

    标签: nginx configuration


    【解决方案1】:

    Nginx 有一个用于此配置模式的 include 指令。

    【讨论】:

    • 我刚刚在正确的地方写了include /path/file。文件本身已被读取。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-01
    • 1970-01-01
    • 2021-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多