关注分享主机优惠活动
国内外VPS云服务器

Nginx配置文件中按位置配置的各种场景

请求如下(示例):nginx服务:http://127.0.0.1:80后台服务:http://127.0.0.1:8088测试url地址:http://127.0.0.1: 8088/test/

场景1: nginx配置:

location/test/{ proxy _ pass http://127 . 0 . 0 . 1:8088/;}请求地址:http://127 . 0 . 0 . 1/test/API/find all

实际上服务请求地址是:http://127 . 0 . 0 . 1:8088/API/find all。

规则:位置以“/”结尾;,proxy_pass终于有& rdquo/& quot;结果是proxy_pass+url中位置最后一个斜杠之后的部分。

二。nginx配置:

位置/测试{ proxy _ pass http://127 . 0 . 0 . 1:8088/;}请求地址:http://127 . 0 . 0 . 1/test/API/find all

实际上服务请求地址是:http://127 . 0 . 0 . 1:8088//API/find all。

规则:位置最后无"/& ldquo;,proxy_pass终于有& rdquo/& quot;结果是proxy_pass+/+url中位置的最后一个斜杠之后的部分。

情景三。nginx配置:

location/test/{ proxy _ pass http://127 . 0 . 0 . 1:8088;}请求地址:http://127 . 0 . 0 . 1/test/API/find all

实际上服务请求地址是:http://127 . 0 . 0 . 1:8088/test/API/find all。

规则:位置以“/”结尾;,proxy _ pass last none & rdquo/& quot;结果是proxy_pass+location+url中location之后的部分(不包括第一个/)

情景四。nginx配置:

位置/测试{ proxy _ pass http://127 . 0 . 0 . 1:8088;}请求地址:http://127 . 0 . 0 . 1/test/API/find all

实际上服务请求地址是:http://127 . 0 . 0 . 1:8088/test/API/find all。

规则:位置最后无"/& ldquo;,proxy _ pass last none & rdquo/& quot;结果是proxy _ pass+location+& ldquo;/& rdquo;URL中位置后面的部分(不包括第一个/)

下面配置的规则可以参考上面的场景。

场景5。nginx配置:

location/test/{ proxy _ pass http://127 . 0 . 0 . 1:8088/server/;}请求地址:http://127 . 0 . 0 . 1/test/API/find all

实际上服务请求地址是:http://127 . 0 . 0 . 1:8088/server/API/find all。

不及物动词nginx配置:

位置/测试{ proxy _ pass http://127 . 0 . 0 . 1:8088/server/;}请求地址:http://127 . 0 . 0 . 1/test/API/find all

实际上服务请求地址是:http://127 . 0 . 0 . 1:8088/server//API/find all。

七。nginx配置:

位置/测试{ proxy _ pass http://127 . 0 . 0 . 1:8088/server/;}请求地址:http://127 . 0 . 0 . 1/test/API/find all

实际上服务请求地址是:http://127 . 0 . 0 . 1:8088/server API/find all。

八。nginx配置:

位置/测试{ proxy _ pass http://127 . 0 . 0 . 1:8088/server;}请求地址:http://127 . 0 . 0 . 1/test/API/find all

实际上服务请求地址是:http://127 . 0 . 0 . 1:8088/server/API/find all。

以上摘要是nginx配置文件中的位置& ldquo/& rdquo;关于配置的说明。

这就是这篇关于Nginx配置文件中位置配置的文章。关于Nginx配置文件位置配置的更多信息,请搜索主机频道zhujipindao以前的文章。或者继续浏览下面的相关文章。希望大家支持主机频道zhujipindao。以后多来com!

未经允许不得转载:主机频道 » Nginx配置文件中按位置配置的各种场景

评论 抢沙发

评论前必须登录!