1

我正在尝试将任何缺少文件扩展名的请求定向到我的快速服务器,除了我想转到我的连接服务器的/and之外。应该从连接服务器请求。这是我所拥有的:/dashboard/dashboard/dashboard.html

server {
    listen 80;
    server_name myserver;

    index index.html;

    location @connect {
        proxy_pass http://localhost:9001;
    }

    location @express {
        proxy_pass http://localhost:9002;
    }

    location ~* \.(html|js|css|png|jpg|jpeg|gif|ico)$ {
        try_files $uri @connect;
        expires 7d;
    }

    location = / {
        try_files $uri @connect;
    }

    location = /dashboard {
        try_files $uri.html @connect;
    }    

    location / {
        try_files $uri @express;
    }
}

/按预期进入连接服务器,但/dashboard进入我的快速服务器。谁能帮我理解我做错了什么?

4

2 回答 2

2

The solution is to replace:

location = /dashboard {
    try_files $uri.html @connect;
}

with

location = /dashboard {
    proxy_pass http://localhost:9001/dashboard.html;
}

Reference:

于 2013-08-06T14:48:46.853 回答
0

我认为问题是因为您使用过location = /dashboard并且我相信这例如不会匹配/dashboard/,您是否只想匹配确切的位置?我的意思是为什么不使用location /dashboard/(删除=

于 2013-08-04T03:04:25.100 回答