Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.5k views
in Technique[技术] by (71.8m points)

Nginx代理转发,域名

意图是,在nginx上配个location/attendance,所有请求这台nginx的/attendance路由转发到https://example.me.com

// nginx.conf

// upstream
upstream attendance {
  proxy_pass https://example.me.com/
}

// location
server {
        listen       80 default_server;
        ...
        location /attendance {
            proxy_pass http://attendance/;
        }
}

报404 not found

怎么trouble shoot,怎么改,有人指点下吗


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

upstream 到底是https还是http呢? 问题中proxy写的是http.
下面回答假设example.me.com 支持http

// upstream
upstream attendance {
  server  example.me.com ;
}
// location
server {
        listen       80 default_server;
        ...
        location /attendance {
        # location和proxy_pass后面的斜线需要注意.如果需要访问example的/attendance路径,proxy_pass后不能加斜线.
            proxy_pass http://attendance;
        }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...