我有一个服务器view.example.com,我必须接受这样的请求:view.example.com/1234 - domain + 4 numbers / letters。
我想做的是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/;
}
}
Arek
答案 0 :(得分:0)
刚检查过这个:
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;
}
}
它似乎可以解决问题 - 任何更好的解决方案?
Arek