全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1752|回复: 4

请问反代的NGINX绑定多域名如何跳转到主域名?【已解决】

[复制链接]
发表于 2018-7-15 15:47:55 | 显示全部楼层 |阅读模式
本帖最后由 formroot 于 2018-7-15 20:07 编辑

NGINX是反代的,绑定了a.com b.com c.com d.com 想不管输入哪个地址全部跳转到a.com 试了return 301  rewrite "^/(.*)$"   这些都不行,都提示重定向太多。

该怎么写呢?谢谢


  1. server {
  2.         listen 80;
  3.         server_name a.com b.com c.com d.com;
  4.         index index.html index.htm index.php;
  5.         access_log off;
  6.         location / {
  7.                 proxy_set_header X-Real-IP $remote_addr;
  8.                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  9.                 proxy_set_header Referer http://a.com;
  10.                 proxy_set_header Host $host;
  11.                 proxy_set_header Cookie $http_cookie;
  12.                 proxy_pass http://127.0.0.1;
复制代码
发表于 2018-7-15 20:02:35 | 显示全部楼层
  1. if ($host != "a.com") {
  2.     return 301 http://a.com$request_uri;
  3. }
复制代码
 楼主| 发表于 2018-7-15 20:07:26 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-19 18:22 , Processed in 0.056940 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表