如何在文件路径中使用变量名?
ssl_certificate /home/ec2-user/.certificados/$server_name.crt;
ssl_certificate_key /home/ec2-user/.certificados/$server_name.key;
Run Code Online (Sandbox Code Playgroud)
Lek*_*eyn 41
您不能在每个指令中使用变量。ssl_certificate
被视为文字字符串,并且是许多不支持变量的指令之一。
要为主机指定不同的证书,您必须将其明确写入服务器块中:
server {
server_name example.com;
ssl_certificate /home/ec2-user/.certificados/example.com.crt;
ssl_certificate_key /home/ec2-user/.certificados/example.com.key;
# ...
}
server {
server_name example.net;
ssl_certificate /home/ec2-user/.certificados/example.net.crt;
ssl_certificate_key /home/ec2-user/.certificados/example.net.key;
# ...
}
# ...
Run Code Online (Sandbox Code Playgroud)
如果您对复制配置感到不舒服,请创建模板并使用这些模板生成 nginx 配置。另请参阅http://nginx.org/en/docs/faq/variables_in_config.html。
小智 12
您可以使用自nginx 1.15.9(2019 年 2 月 26 日)以来的变量
请注意,使用变量意味着将为每次 SSL 握手加载证书,这可能会对性能产生负面影响
不过,要注意与变化nginx的12年1月15日(2019年4月16日):
修正:如果在“ssl_certificate”或“ssl_certificate_key”指令中使用了变量并且启用了 OCSP 装订,则可能会在工作进程中发生分段错误。
归档时间: |
|
查看次数: |
14911 次 |
最近记录: |