英镑:将httpredirect到通配符子域的https

我有一个服务器(debian jessie)用varnish和apachepipe理多个域,我想用磅来redirecthttpstream量到https。

由于HeadRequire指令允许使用正则expression式,因此我也尝试在Redirect中使用正则expression式:

ListenHTTP Address 1.2.3.4 Port 80 ## allow PUT and DELETE also (by default only GET, POST and HEAD) xHTTP 0 RewriteLocation 0 Service "myHost" HeadRequire "^Host: (.+)\.myserver\.net" Redirect 301 "http://\1.myserver.net" End End 

但不幸的是我得到ERR_INVALID_REDIRECT

有没有办法让英镑做通配符redirect?

curl输出:

 $ curl -v http://prova.myserver.net:80/ * Hostname was NOT found in DNS cache * Trying 1.2.3.4... * Connected to prova.myserver.net (1.2.3.4) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.38.0 > Host: prova.myserver.net:80 > Accept: */* > * HTTP 1.0, assume close after body < HTTP/1.0 301 Moved Permanently < Location: http://%5c1.myserver.net/ < Content-Type: text/html < Content-Length: 148 < * Closing connection 0 <html><head><title>Redirect</title></head><body><h1>Redirect</h1><p>You should go to <a href="http://%5c1.myserver.net/">here</a></p></body></html> 

总之:不可能。

基于磅文档的Redirect指令不允许任何模式(或正则expression式)。 而且这也是从逻辑上来说,每个服务可能有许多HeadRequire指令(所有这些指令都应该满足redirect工作的需要),所以如果你使用了两个具有不同正则expression式的HeadRequire指令,那么Redirect就无法猜测他们有你想要的反向引用。

你也问过关于redirect到https,但你的例子redirect到http。 您可能省略了“s”,如下所示:

 ListenHTTP Address 1.2.3.4 Port 80 Service HeadRequire "Host:.*some1.myserver.net.*" Redirect "https://some1.myserver.net" End Service HeadRequire "Host:.*some2.myserver.net.*" Redirect "https://some2.myserver.net" End End ListenHTTPS Address 1.2.3.4 Port 443 # first domain Cert "/etc/pki/tls/letsencrypt_pound/pound_some1.pem" # second domain Cert "/etc/pki/tls/letsencrypt_pound/pound_some2.pem" Disable SSLv3 End