在服务器上运行nginx,对外端口443。
而在服务器内部用python开发了一个web服务器,端口444。
现在希望外部访问过来的url中包含"ABC"的交给444端口的python服务器处理,其他的交给443端口的nginx服务器处理。
nginx的conf文件配置如下:
只写一个serve,在location中判断。
location / {
if ($request_uri ~* "ABC"){
proxy_pass http://127.0.0.1:444;
}
root html;
index index.html index.htm;
}
其中 if后的 $request_uri ~* "ABC" 指请求过来的url中包含ABC。
如果包含,则为真,走proxy_pass后面的本机地址127.0.0.1的端口444。
否则走root规定的html目录。
nginx代理,转发本机其他端口,url过滤。
最新推荐文章于 2024-04-07 14:27:20 发布