AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-196214

eternaltyro's questions

Martin Hope
eternaltyro
Asked: 2019-05-22 23:02:50 +0800 CST

使用 Nginx 变量代替 CSP 值

  • 1

我有一个相当长的 Content-Security-Policy 标头值,我必须将它放在几个location块中。

是否可以在配置中声明一个具有我的长 CSP 字符串值的变量,然后在整个块中使用该变量代替字符串location?

像这样的东西:

location / {
  ...
  set_header Content-Security-Policy $csp_string;
  ...
}
...
location /somethingelse {
  ...
  set_header Content-Security-Policy $csp_string;
  ...
}
nginx
  • 1 个回答
  • 704 Views
Martin Hope
eternaltyro
Asked: 2017-09-22 23:58:16 +0800 CST

Chef 模板:通过另一个变量查找哈希键

  • 0

我正在尝试为不同的环境构建 nginx 文件。我的食谱有一个像这样的哈希图:

domain = {
  production: {
    public: 'example.com',
    internal: 'example.dev'
  },
  staging: {
    public: 'examplestage.com',
    internal: 'examplestage.dev'
  }
}

template '/etc/nginx/conf.d/example.conf' do
  source 'example.conf.erb'
  variables(
    :domain => domain,
  )
end

在我的模板中,我想做这样的事情:

...
server <%= @domain[node.chef_environment][:public] %> <%= @domain[node.chef_environment][:public] %>;
...

我试图让它评估为这样的东西,具体取决于节点所属的环境staging或production:

server example.com example.dev;

问题是,该node.chef_environment部分没有被插值。我该如何解决这个问题?

chef
  • 1 个回答
  • 1400 Views
Martin Hope
eternaltyro
Asked: 2013-10-26 00:18:39 +0800 CST

Varnish 无法识别 req.hash

  • 4

我在 Redhat 上安装了 Varnish 3.0.2,并且在添加 vcl_hash 部分后服务 varnish 启动失败。我做了清漆,然后使用 vcl.load 加载了 vcl

vcl.load default default.vcl

Message from VCC-compiler:
Unknown variable 'req.hash'
At: ('input' Line 24 Pos 9)
    set req.hash += req.url;
--------########------------

Running VCC-compiler failed, exit 1

猫默认.vcl

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

sub vcl_recv {
  if( req.url ~ "\.(css|js|jpg|jpeg|png|swf|ico|gif|jsp)$" ) {
    unset req.http.cookie;
  }
}

sub vcl_hash {
  set req.hash += req.url;
  set req.hash += req.http.host;
  if( req.httpCookie == "JSESSIONID" ) {
    set req.http.X-Varnish-Hashed-On = regsub( req.http.Cookie, "^.*?JSESSIONID=([a-zA-z0-9]{32}\.[a-zA-Z0-9]+)([\s$\n])*.*?$", "\1" );
    set req.hash += req.http.X-Varnish-Hashed-On;
  }
  return(hash);
}

有什么问题?

redhat
  • 1 个回答
  • 2317 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve