全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

nginx通配符能自动反代吗?

[复制链接]
发表于 2014-4-14 07:52:20 | 显示全部楼层 |阅读模式

server {
        listen 80;
        server_name ~^(www\.)?(?<domain>.+)\..+$;
        index index.php index.html index.htm;

        location / {
                default_type text/html;
                proxy_cache amproxy;
                subs_filter_types text/css text/xml;
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Referer http://$domain.xxx.com;
                proxy_set_header Host $domain.xxx.com;
                proxy_pass http://$domain.xxx.com;
                proxy_set_header Accept-Encoding "";
        }
}

这个配置实现不了呢!高手帮忙看看。
发表于 2014-4-14 11:21:16 | 显示全部楼层
server_name 唯一支持的通配符就是星号  *
发表于 2014-4-14 13:11:36 | 显示全部楼层
cun 发表于 2014-4-14 11:21
server_name 唯一支持的通配符就是星号  *

你不知道先匹配通配符,再匹配正则表达式的吗?
发表于 2014-4-14 13:16:37 | 显示全部楼层
不需要那么多header,被反代的一般不会随便接收你的xff:
  1. server {
  2.     server_name .*;
  3.     resolver 8.8.8.8;
  4.     location / {
  5.         proxy_pass $scheme://$host$request_uri;
  6.         proxy_set_header host $http_host;
  7.     }
  8. }
复制代码
 楼主| 发表于 2014-4-17 09:58:56 | 显示全部楼层
★Extreme★ 发表于 2014-4-14 13:16
不需要那么多header,被反代的一般不会随便接收你的xff:

我解决了。还有其他变量。不是简单的反代别人网站
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-31 00:24 , Processed in 0.071042 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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