nginx代理远程nginx的所有流量

use*_*674 37 proxy nginx traffic

我有2台服务器,

  1. 与IP xx.xx.xx.xx,位于德国...(运行前端:nginx(静态内容),后端:Apache2)

  2. 与IP yy.yy.yy.yy,位于意大利......

目前所有请求都是通过IP xx.xx.xx.xx发送到服务器, 如何使用nginx代理从xx.xx.xx.xx到yy.yy.yy.yy的所有流量...

          request                           proxy, request
Internet     ->       xx.xx.xx.xx(nginx)         ->             yy.yy.yy.yy(nginx, Apache)
             <-                                  <-
          response                          proxy, response
Run Code Online (Sandbox Code Playgroud)

谢谢 ...

Vla*_*idt 96

为他人.主题的答案是配置nginx像:

server {
  listen 80;
  server_name mydomain.com;
    location / {
      access_log off;
      proxy_pass http://mydomain.com:8080;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
Run Code Online (Sandbox Code Playgroud)

  • `location /`匹配所有路径吗?或只有根路径'\'? (3认同)
  • @pomo 根据此处的指南 http://nginx.org/en/docs/http/ngx_http_core_module.html#location 它将匹配所有嵌套查询,例如 site.com/index.html 但不匹配根查询又名 site.com/ (2认同)