我将nginx用作站点微服务的反向代理,并使用docker进行了部署。我正在更新nginx.config
文件,以将对子域的请求(先前的客户端要求)发送到路径。我想将tool.example.com
发送到example.com/tool
。
但是,问题是tool.example.com
重定向到example.com/tool/tool/tool/tool/tool/tool/tool/tool/tool/tool/tool
,这不是很有用。
这是我的配置:
# handle HTTP requests for the old tool.example.com
server {
server_name tool.example.com;
listen 80;
listen [::]:80;
rewrite ^ http://example.com/tool permanent;
}
# handle HTTPS requests for the old tool.example.com
server {
server_name tool.example.com;
listen 443 ssl http2;
listen [::]:443 ssl http2;
rewrite ^ https://example.com/tool permanent;
}
# send HTTP requests for example.com to HTTPS
server {
listen 80;
listen [::]:80;
server_name example.com;
return 301 https://example.com$request_uri;
}
# handle HTTPS requests for example.com
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
keepalive_requests 500;
keepalive_timeout 70;
proxy_intercept_errors on;
error_page 400 404 502 /errors/error.html;
location /tool {
proxy_pass http://tool_servers/;
proxy_redirect off;
proxy_set_header Host host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
client_max_body_size 50M;
}
}
我看不到配置中的什么导致nginx不断追加/tool
,直到达到重定向限制为止,但是显然有不对的地方。我在做什么错了?