转发我的http请求从我的ip到另一台服务器

我需要将来自旧服务器IP的任何http请求转发给我的新IP。

我迁移了服务器,并且有几个域的TTL很高,我无法更新。 是否有可能从运行centos / whm / php / apache 2+的一台服务器获取所有HTTP请求,并将它们转发给新的ip?

由于我有数百个域,我更喜欢一个解决scheme,涉及在Linux框中运行一个应用程序,将自动推送请求到新的框。

思考?

我试过使用IP表和转发所有传入连接使用preroute链,但似乎这只适用于转发到内部IP地址,而新的IP是外部的。

基本上你需要在你的旧IP上设置nginx 。 而你应该改变它的configuration,使其充当反向代理,如下所示:

 server { listen 80 default; server_name localhost; access_log /var/log/nginx/localhost.access.log; location / { proxy_pass http://your_new_ip_here:80/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 180; proxy_read_timeout 180; charset utf-8; } }