小编Pot*_*thu的帖子

什么时候必须在 Nginx 配置中使用引号?

我见过人们使用过多的引号

add_header 'Access-Control-Allow-Origin' '*';
Run Code Online (Sandbox Code Playgroud)

我见过人们不使用引号

add_header Access-Control-Allow-Origin *;
Run Code Online (Sandbox Code Playgroud)

据我所知,两者都可以正常工作,所以你什么时候真正需要使用引号?

nginx

30
推荐指数
2
解决办法
2万
查看次数

ssh is no longer using ~/.ssh/config

I cannot ssh anything I was able to. After a little digging I found out that it's not reading ssh config from my home directory.

$ ssh -xvvv server
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
(...)
Run Code Online (Sandbox Code Playgroud)

When on an identical computer of a friend, where everything works it looks like this:

$ ssh -xvvv server
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/kuba/.ssh/config
(...)
Run Code Online (Sandbox Code Playgroud)

It worked earlier and I am not aware …

ssh

25
推荐指数
2
解决办法
5万
查看次数

如何根据 X-forwarded-for 标头拒绝对资源的访问

我试图根据在 X-forwarded-for 标头中传递的客户端 IP 限制对 Nginx 后面资源的访问。Nginx 在 Google Cloud Platform 上的 Kubernetes 集群上的容器中运行,真实客户端 ip 仅在 x-forwarded-for 标头中传递

到目前为止,我已经设法使用以下代码为单个 IP 执行此操作:

set $allow false;
if ($http_x_forwarded_for ~* 123.233.233.123) {
    set $allow true;
}
if ($http_x_forward_for ~* 10.20.30.40) {
    set $allow false;
}
if ($allow = false) {
    return 403;
}
Run Code Online (Sandbox Code Playgroud)

但是我如何为整个 IP 范围做到这一点?手动指定数百个 IP 没有多大意义。

感谢所有帮助

nginx

16
推荐指数
2
解决办法
3万
查看次数

清漆无法识别 req.hash

我在 Redhat 上安装了 Varnish 3.0.2,并且在添加 vcl_hash 部分后服务 varnish 启动失败。我做了 varnishd 然后使用 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
Run Code Online (Sandbox Code Playgroud)

猫默认.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" ) { …
Run Code Online (Sandbox Code Playgroud)

redhat varnish

4
推荐指数
1
解决办法
2258
查看次数

标签 统计

nginx ×2

redhat ×1

ssh ×1

varnish ×1