Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k 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 OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...