场景 1
很多时候,我们在做项目过程中,可能需要 用到相同的 ip,相同的端口,但 又要区分不同的应用等,这时候 我们就需要用
nginx 做代理,
如 :我们项目中 要用到图片,上传的时候,我们会配置一个目录,通过java代码写入到该文件夹,然后可以通过某个地址可以访问到,这时候 就得用nginx了。
#利用nginx根目录指定到图片目录,这个目录相当于 wwww目录。
location / {
root /public;
index index.html index.htm;
}
#利用重定向 并且带上相应的端口。必须加入 proxy_set_header Host $host:8080;
location /schoolSafe {
proxy_set_header Referer $http_referer;
proxy_set_header Host $host:8080;
proxy_pass http://127.0.0.1:8080/schoolSafe;
}