nginx反向代理nginx.conf配置文件示例:访问不同路径反向代理到不同端口

亦凉 2024-02-05 21:57 140阅读 0赞

比如我们监听 9001 端口,然后把访问不同路径的请求进行反向代理:

  • 把访问 http://127.0.0.1:9001/edu 的请求转发到 http://127.0.0.1:8080
  • 把访问 http://127.0.0.1:9001/vod 的请求转发到 http://127.0.0.1:8081

这种要怎么配置呢,首先同样打开主配置文件,然后在 http 模块下增加一个 server 块:

  1. server {
  2. listen 9001;
  3. server_name localhost;
  4. location ~ /edu/ {
  5. proxy_pass http://127.0.0.1:8080;
  6. }
  7. location ~ /vod/ {
  8. proxy_pass http://127.0.0.1:8081;
  9. }
  10. }

发表评论

表情:
评论列表 (有 0 条评论,140人围观)

还没有评论,来说两句吧...

相关阅读