搭建了一台服务器,通过http://ip:port/home/page这个url可以访问,curl可以拿到结果。
我这台服务器绑定了一个域名,假设为www.test.com,现在我想通过http://www.test.com/home/page这个链接去访问http://ip:port/home/page这个url拿到相同的结果。
所以我配置了nginx,但是没能实现效果。我nginx配置如下:
upstream tomcats {
server 127.0.0.1:8081 weight=1 max_fails=2 fail_timeout=30s;
}
server {
listen 80;
server_name localhost;
keepalive_requests 120;
location /(.*?)/ {
proxy_pass http://tomcats/$1/;
expires 2m;
}
}
location那里改为如下的代码也不行:
location / {
proxy_pass http://tomcats;
expires 2m;
}
求指教,这个http转发应该怎么配置?