location /
{
root /www/dist;
try_files $uri $uri/ /index.html;
index index.html;
}
上面的代码时主页面,我想访问 /test 的时候返回另一个文件夹test中的页面,我用下面的代码好像没有用
location /test
{
root /www/test;
try_files $uri $uri/ /index.html;
index index.html;
}
玩法有问题,URL这样的配置,要配置代理的。
举个例子说明,/ 这个用8088端口侦听,/test 用8089 侦听,那访问/test 的配置,就是如下:
server {
listen 8088 default_server;
listen [::]:8088 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
location /test/ {
proxy_pass http://192.168.159.111:8089/;
}
}