NutzCN Logo
问答 nginx 是否可以 forward 到另外一个地址上?
发布于 2818天前 作者 Rekoe 2607 次浏览 复制 上一个帖子 下一个帖子
标签:

RT
请求

 www.abc.com/action?id=1

的时候forward到

www.def.com/action?id=1

2 回复

同时把

 www.abc.com/action?id=1

的ip也带给

www.def.com/action?id=1

找到一个

https://calvin.me/forward-ip-addresses-when-using-nginx-proxy/
# redirect calvin.me to https
server {
  listen      80 default_server;
  server_name calvin.me;
  return 301 https://calvin.me;
}

# redirect www prefix to https
server {
  listen      80;
  server_name www.calvin.me;
  return 301 https://www.calvin.me;
}

server {
  #listen 80;
  listen 443 ssl default_server;
  server_name calvin.me;
  ssl_certificate /etc/nginx/ssl/calvin.me.crt;
  ssl_certificate_key /etc/nginx/ssl/calvin.me.key;

  location / {
    proxy_set_header  Host $host;
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header  X-Forwarded-Proto https;
    proxy_set_header  X-Forwarded-For $remote_addr;
    proxy_set_header  X-Forwarded-Host $remote_addr;
    proxy_pass        http://wp.calvin.me;
  }
}
添加回复
请先登陆
回到顶部