小编net*_*ain的帖子

如何配置 nginx 位置以共享常用配置选项?

如何为一组位置配置共享配置块?

    location / {

            proxy_pass        http://127.0.0.1:9000/;
            proxy_redirect    off;
            proxy_set_header  Host             $http_host;
            proxy_set_header  X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;

            proxy_cache cache-test;
            proxy_cache_valid 200 302 24h;
            proxy_cache_valid 404 60s;
            add_header X-Cache-Status $upstream_cache_status;

    }


    location /api/0.1/user{
            proxy_cache_key /user/$http_authorization;
    }
Run Code Online (Sandbox Code Playgroud)

现在,如果我尝试访问 /api/0.1/user 然后我会得到 404 因为它没有将请求传递给 127.0.0.1:9000

nginx

51
推荐指数
2
解决办法
4万
查看次数

标签 统计

nginx ×1