Important command line arguments 重要命令行参数 ——————————–

There a two command line arguments you have to set when starting Varnish, these are: 启动Varnish时,你需要设置两个重要的命令行参数,它们是: * what TCP port to serve HTTP from, and * 提供HTTP服务的TCP端口,以及 * where the backend server can be contacted. * 可连接上的后端服务器

If you have installed Varnish through using a provided operating system bound package 假如你用每个操作系统相应的安装包安装Varnish, you will find the startup options here: 你可以找到启动参数:

  • Debian, Ubuntu: /etc/default/varnish
  • Red Hat, Centos: /etc/sysconfig/varnish
  • FreeBSD: /etc/rc.conf (See also: /usr/local/etc/rc.d/varnishd)

‘-a’ listen_address ‘-a’ 监听地址 ^^^^^^^^^^^^^^^^^^^^^

The ‘-a’ argument defines what address Varnish should listen to, and service HTTP requests from. 参数’-a’指定监听地址,Varnish以此地址提供HTTP服务。

You will most likely want to set this to ”:80” which is the Well 通常你倾向于把其设置为”:80”,80是大家熟知的HTTP服务端口。 Known Port for HTTP.

You can specify multiple addresses separated by a comma, and you 你可以通过冒号分隔的方式以指定多个地址, can use numeric or host/service names if you like, Varnish will try 且可根据个人偏好使用数字或者主机/服务名,Varnish将 to open and service as many of them as possible, but if none of them 尽可能地开启这些地址以提供服务, can be opened, varnishd will not start. 但若没有任何地址被开启,’varnishd’不会启动。

Here are some examples:: 如下为参数’-a‘的一些示例:

-a :80 -a localhost:80 -a 192.168.1.100:8080 -a ‘[fe80::1]:80’ -a ‘0.0.0.0:8080,[::]:8081’

If your webserver runs on the same machine, you will have to move 若你的网页服务器也运行在该机器上,你首先应该 it to another port number first. 修改它的端口号。

‘-f’ VCL-file or ‘-b’ backend ‘-f’ VCL文件 或者 ‘-b’ 后端 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Varnish needs to know where to find the HTTP server it is caching for. Varnish需要知道其要缓存的HTTP服务器地址, You can either specify it with the ‘-b’ argument, or you can put it in your own VCL file, specified with the ‘-f’ argument. 你可以通过参数’-b’指定,或者通过参数’-f’对应的VCL文件。

Using ‘-b’ is a quick way to get started:: 使用参数’-b’是一种比较快捷的方式,例如:

-b localhost:81 -b thatotherserver.example.com:80 -b 192.168.1.2:80

Notice that if you specify a name, it can at most resolve to one IPv4 需要注意的是,如果你指定的是一个名字,它会尽可能地被解析为一个IPv4地址 and one IPv6 address. 和一个IPv6地址。

If you go with ‘-f’, you can start with a VCL file containing just:: 假如你使用参数’-f’,则对应的VCL配置文件的起始内容可设置为:

backend default {
.host = “localhost:81”;

}

which is exactly what ‘-b’ does. 其等同于使用参数’-b’。

In both cases the built-in VCL code is appended. 在这种情况下,内置的VCL代码生效。

Other options 其它选项 ^^^^^^^^^^^^^

Varnish comes with an abundance of useful command line arguments. We recommend that you study them but not necessary use them all, but to get started, the above will be sufficient. Varnish有丰富的命令参数。我们推荐你研究下这些参数,但没有必要全部使用它们,如果要启动Varnish,上面的介绍已经足够。

By default Varnish will use 100 megabytes of malloc(3) storage 默认情况下,Varnish会通过函数malloc分配100M的内存空间 for caching objects, if you want to cache more than that, you 以缓存对象,如果你需要更大的缓存空间,你 should look at the ‘-s’ argument. 应该看下参数’-s’。

If you run a really big site, you may want to tune the number of 假如你在运行着一个大网站,你可能想通过选项’-p’调整 worker threads and other parameters with the ‘-p’ argument, 工作线程数或其它的参数, but we generally advice not to do that unless you need to. 但通常我们建议你在需要的时候才使用它。

Before you go into production, you may also want to revisit the 在你使用这个产品前,你可能想重访问 chapter 一些章节 Security first to see if you need to partition administrative Security first 查看你是否需要区分管理员权限。 privileges.

For a complete list of the command line parameters please see 命令行参数的完整列表,请查阅: OPTIONS. OPTIONS.

Previous topic

Security first

Next topic

CLI - bossing Varnish around

This Page