假设我有
网站A 192.168.1.2:8080/aa
网站B 192.168.1.2:8081/bb
我只有一个域名C.com
我如何设置目录反向代理的方法
C.com/aa 指向 192.168.1.2:8080/aa
C.com/bb 指向 192.168.1.2:8081/bb
可以实现么?应该怎么配置呢
假设我有
网站A 192.168.1.2:8080/aa
网站B 192.168.1.2:8081/bb
我只有一个域名C.com
我如何设置目录反向代理的方法
C.com/aa 指向 192.168.1.2:8080/aa
C.com/bb 指向 192.168.1.2:8081/bb
可以实现么?应该怎么配置呢
这个肯定是可以的,你先设置一个静态目录网站,然后手动配置代理
location /aa/ {
proxy_pass http://192.168.1.2:8080/aa/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /bb/ {
proxy_pass http://192.168.1.2:8081/bb/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}