简体   繁体   English

如何为具有特殊字符的URL配置nginx proxy_pass

[英]How do I configure an nginx proxy_pass for a url with special characters

My configuration uses a proxy path for a url prefixed by v0.1 . 我的配置使用代理路径作为以v0.1为前缀的v0.1 Nginx doesn't proxy for my backend. Nginx不代理我的后端。 When I change to just v everything works as it should. 当我改为v一切都按预期工作。 My suspicion is that the . 我怀疑是. has special meaning. 有特殊意义。

How should I modify this configuration for it to work? 我该如何修改此配置才能使用?

 location /v0.1 {
    proxy_pass http://localhost:8080/;
 }

I don't know what your configuration is supposed to do. 我不知道你的配置应该做什么。 But I have tested two similar scenarios which both work as expected. 但我测试了两个类似的场景,它们都按预期工作。

The first will delete the leading /v0.1 from the URI before sending it upstream, so the service on 8080 never sees the /v0.1 part: 第一个将在向上游发送之前从URI中删除前导/v0.1 ,因此8080上的服务永远不会看到/v0.1部分:

location /v0.1/ {
    proxy_pass http://localhost:8080/;
}

The second will pass the entire URI (including the /v0.1 prefix) to the upstream: 第二个将整个URI(包括/v0.1前缀)传递给上游:

location /v0.1 {
    proxy_pass http://localhost:8080;
} 

See this document for details. 请参阅此文档了解详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM