我有一个服务器view.example.com,我必须采取这样的请求:view.example.com/1234-域4的数字/字母。
我想做的是proxy_pass请求到我的本地服务:192.168.33.10/view/1234
如何将nginx配置写入:
到目前为止,我已经:
server {
server_name view.example.com;
listen 80;
location ~ '^/(?<hash>[a-zA-Z0-9\-_]{4})/?$' {
# rewrite - which I should probably use but not sure how
proxy_pass http://192.168.33.10/view/;
}
}
阿雷克
刚刚检查了这个:
server {
server_name view.example.com;
listen 80;
location ~ '^/(?<hash>[a-zA-Z0-9\-_]{4})/?$' {
rewrite ^ /view/$hash break;
proxy_pass http://192.168.33.10;
}
}
它似乎做了诀窍-有更好的解决方案吗?
阿雷克