我有一个服务器运行一堆docker图像(基本上只是托pipe一堆网站)
他们都有不同的域名,都指向服务器的IP
(可以说服务器IP是111.222.333.444)
(我的域名是www.one.com,www.two.com,www.three.com)
目前,docker服务器将所有导出端口80映像到另一个端口上的服务器:
所以,如果我访问URL:端口,那么网站显示。
但我想使用虚拟主机,所以我可以访问每个URL的端口80,它只是redirect到相关的端口。
我知道如何用apache来做到这一点,也许可以用nginx来解决这个问题。
但我听说这是什么鱿鱼是真正的(加上apache作为虚拟主机似乎是非常重的重量)
我已经在我的ubuntu12.04服务器上安装了squid3
这是我的squid.conf到目前为止
http_port 80 accel defaultsite=www.one.com no-vhost cache_peer 127.0.0.1 parent 5080 0 no-query originserver name=YourAccelNameHere acl your_site_acl dstdomain www.one.com http_access allow your_site_acl cache_peer_access YourAccelNameHere allow your_site_acl cache_peer_access YourAccelNameHere deny all
从阅读教程,“应该”转发到本地主机上的端口5080 www.one.com(但事实并非如此)
我真的不知道鱿鱼,从我所有的谷歌search,我似乎无法find一个简单的教程做我想做的事情。
任何人都可以指向我一个很好的教程,或者甚至更好地为我提供一个squid.conf,这将做我以后?
谢谢
自己回答
我的解决scheme是:
我用清漆解决了它
apt-get install varnish
然后我设定我的
/etc/default/varnish
至
START=yes NFILES=131072 MEMLOCK=82000 DAEMON_OPTS="-a :80 \ -T localhost:6082 \ -f /etc/varnish/default.vcl \ -S /etc/varnish/secret \ -s malloc,256m"
然后设置我的
/etc/varnish/default.vcl
至
backend default { .host = "127.0.0.1"; .port = "80"; } backend one_website { .host = "127.0.0.1"; .port = "5080"; } backend two_website { .host = "127.0.0.1"; .port = "5180"; } ## Multiple virtual host sub vcl_recv { if (req.http.host ~ "^www.default.com(:[0-9]+)?$") { set req.backend = default; } else if (req.http.host ~ "^www.one.com(:[0-9]+)?$") { set req.backend = one_website; } else if (req.http.host ~ "^www.two.com(:[0-9]+)?$") { set req.backend = two_website; } } ## Fetch sub vcl_fetch { ## Remove the X-Forwarded-For header if it exists. remove req.http.X-Forwarded-For; ## insert the client IP address as X-Forwarded-For. This is the normal IP address of the user. set req.http.X-Forwarded-For = req.http.rlnclientipaddr; ## Added security, the "w00tw00t" attacks are pretty annoying so lets block it before it reaches our webserver if (req.url ~ "^/w00tw00t") { error 403 "Not permitted"; } ## Deliver the content return(deliver); } ## Deliver sub vcl_deliver { ## We'll be hiding some headers added by Varnish. We want to make sure people are not seeing we're using Varnish. ## Since we're not caching (yet), why bother telling people we use it? remove resp.http.X-Varnish; remove resp.http.Via; remove resp.http.Age; ## We'd like to hide the X-Powered-By headers. Nobody has to know we can run PHP and have version xyz of it. remove resp.http.X-Powered-By; }
我希望可以帮助别人面对这个问题!