我正在尝试创建一个条件代理,该代理将以'DirectToHTTP'结尾的URL(来自localhost:7012
)代理到另一个http服务器(位于localhost:8012
)。
配置文件的其余部分运行良好(在https中重定向至localhost:877X
),但是代理不起作用。
我怎么了? (我是nginx和Web服务器的新手)
非常感谢! :)
Nginx配置文件的主要内容:
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 7012 ;
server_name someservername;
set $new_uri "${request_uri}";
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
if ($new_uri ~ (.*)DirectToHTTP) {
proxy_pass http://localhost:8012;
break;
}
}
if ($request_method = GET) {
return 301 https://localhost:8773$new_uri;
}
if ($request_method = POST) {
return 307 https://localhost:8773$new_uri;
}
if ($request_method = PUSH) {
return 307 https://localhost:8773$new_uri;
}
return 301 https://localhost:8773$new_uri;
}
}