我想和你分享我的问题。我有两个不同的restApis,它们部署在单独的Tomcat(端口8082和8084)中。 2部署工作正常,我可以通过浏览器访问这两个应用程序。 现在我想用Nginx建立一种网关,以便用url参数访问我的应用程序(例如),所以我配置了nginx.conf:
http {
include mime.types;
default_type application/octet-stream;
upstream genialoserv {
server 127.0.0.1:8082;
}
upstream connexionserv {
server 127.0.0.1:8084;
}
server {
listen 127.0.0.1:83;
server_name genialo;
location /gen {
# Proxy all the requests to Tomcat
proxy_pass http://genialoserv/;
proxy_set_header Host $host;
}
location /con {
# Proxy all the requests to Tomcat
proxy_pass http://connexionserv/;
proxy_set_header Host $host;
}
}
}
结果是当我进入我的localhost时:83我到达Nginx的欢迎页面,因为我想要到达localhost:83 / gen或localhost:83 / con我无法访问api的资源
有关信息,我使用tomcat8和Nginx 1.10在Windows 7上工作,而apis都是.war。