Pergunta

Lets say for simplicity, as i'm a startup on Varnish, i have a single Server having Varnish and Apache together inside. There are multiple Sub-Domains in Apache as Virtual Hosts.

Lets say i have:

  • sub1.example.com
  • sub2.example.com
  • sub3.example.com

Then i ONLY changed Apache's httpd.conf port to:

Listen 8080

Again then now my backend setting in VCL so far is:

backend default{
  .host = "127.0.0.1";
  .port = "8080";
}

Now my question here is:

  • Is it just enough for this kind of setup? Seriously what am i missing here?
  • What i'm still need to be cleard is, first, at the Apache httpd.conf end, is it only need to change the Listen value?

How about this:

NameVirtualHost *:80

and also V.Host settings for each sub-domains:

<VirtualHost *:80>
..
..
</VirtualHost>
  • Do i also need to change those Ports to 8080 please, for Apache side?

Finally in the VCL Configuration, i am seeing such kinda following:

if (req.http.host == ".........com") {
    ..
}

.. in other forums.

  • I DO NOT have this kind of setting inside my VCL
  • So do i need such thing and/or seriously what do i missing for my schema please?

Thanks all!

Foi útil?

Solução

Varnish will be running on the port 80. So, Apache should be running on any other port then port 80. I personally prepare to use port 81 for Apache as port 8080 is normal used by Apache Tomcat.

Listening Apache on port 81. httpd.conf (/etc/httpd/conf/httpd.conf).

Listen 81
NameVirtualHost *:81

Default configuration file for Varnish. default.vcl (/etc/varnish/default.vcl).

backend default {
  .host = "127.0.0.1";
  .port = "81";
}

Virtual Host for sub1.example.net and sub2.example.net. vhosts.conf (/etc/httpd/conf.d/vhosts/example.net.conf).

# vhost : sub1.example.net
<VirtualHost *:81>
  ...
  ServerName sub1.example.net
  ...
  <Directory "/var/www/html/vhosts/example.net/sub1/public_html">
    ...
  </Directory>
  ...
</VirtualHost>

# vhost : sub2.example.net
<VirtualHost *:81>
  ...
  ServerName sub2.example.net
  ...
  <Directory "/var/www/html/vhosts/example.net/sub2/public_html">
    ...
  </Directory>
  ...
</VirtualHost>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top