nginx代理正确的配置,用于返回包括子路径在内的所有内容

时间:2018-01-15 17:54:19

标签: node.js nginx proxy

我需要正确配置nginx代理才能返回所有内容,无论地址为localhost:8000的其他服务是什么。 例子:

example.com               ->  localhost:8000
example.com/api/book      ->  localhost:8000/api/book
example.com/js/main.js    ->  localhost:8000/js/main.js
example.com/css/main.css  ->  localhost:8000/css/main.css

POST GET PUT DELETE无论如何。 是否可以不指定每个子路径和每个文件扩展名?

1 个答案:

答案 0 :(得分:0)

You just need a simple config

location / {
   proxy_pass http://localhost:8000;
}

This should pass the request as it is with same path, data and http method