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-26763

Quintin Par's questions

Martin Hope
Quintin Par
Asked: 2018-05-13 07:59:33 +0800 CST

调试 Nginx 缓存未命中:尽管代理有效,但仍命中大量未命中

  • 7

我的代理缓存路径设置为非常大

proxy_cache_path  /var/lib/nginx/cache  levels=1:2   keys_zone=staticfilecache:180m  max_size=700m;

并且使用的尺寸只有

sudo du -sh *
14M cache
4.0K    proxy

代理缓存有效设置为

proxy_cache_valid 200 120d;

我通过以下方式跟踪 HIT 和 MISS

add_header X-Cache-Status $upstream_cache_status;

尽管有这些设置,我还是看到了很多 MISS。这是针对我在一小时前故意运行缓存预热器的页面。

我如何调试为什么会发生这些 MISS?我如何确定错过是否是由于驱逐、到期、某些流氓标头等引起的?Nginx 是否为此提供命令?

编辑:完整配置

    # at http level
    proxy_cache_path  /var/lib/nginx/cache  levels=1:2 inactive=400d keys_zone=staticfilecache:180m  max_size=700m;
    proxy_temp_path /var/lib/nginx/proxy;
    proxy_connect_timeout 30;
    proxy_read_timeout 120;
    proxy_send_timeout 120;
    #prevent header too large errors
    proxy_buffers 256 16k;
    proxy_buffer_size 32k;
    #httpoxy exploit protection
    proxy_set_header Proxy "";

    # at server level 
    add_header Cache-BYPASS-Reason $skip_reason;

    # define nginx variables
    set $do_not_cache 0;
    set $skip_reason "";
    set $bypass 0;

    # security for bypass so localhost can empty cache
    if ($remote_addr ~ "^(127.0.0.1|Web.Server.IP)$") {
        set $bypass $http_8X0;
    }

    # skip caching WordPress cookies
    if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
        set $do_not_cache 1;
        set $skip_reason Cookie;
    }

    # Don't cache URIs containing the following segments
    if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php") {
        set $skip_cache 1;
        set $skip_reason URI;
    }

    # https://guides.wp-bullet.com/how-to-configure-nginx-reverse-proxy-wordpress-cache-apache/
    location / {
            proxy_pass http://127.0.0.1:8000;

            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto https;
            proxy_set_header X-Forwarded-Port 443;
            proxy_set_header Host $host;
            proxy_set_header Accept-Encoding "";

            # may need to comment out proxy_redirect if get login redirect loop
            proxy_redirect off;

            proxy_cache_key "$scheme://$host$uri";
            add_header X-Nginx-Cache-Head "$scheme://$host$uri";
            proxy_cache staticfilecache;
            proxy_cache_valid       200 301 302 100d;
            proxy_cache_valid 404 1m;


            add_header Cache-Control public;

            proxy_ignore_headers Expires;
            proxy_ignore_headers  "Cache-Control";
            proxy_ignore_headers X-Accel-Expires;

            proxy_hide_header "Cache-Control";
            proxy_hide_header Pragma;
            proxy_hide_header Server;
            proxy_hide_header Request-Context;
            proxy_hide_header X-Powered-By;
            proxy_cache_revalidate on;

            proxy_hide_header X-AspNet-Version;
            proxy_hide_header X-AspNetMvc-Version;
            #proxy_pass_header X-Accel-Expires;


            add_header X-Nginx-Cache-Status $upstream_cache_status;

            proxy_cache_use_stale  error timeout invalid_header updating http_500 http_502 http_503 http_504;
            proxy_cache_bypass $arg_nocache $do_not_cache $http_8X0;
            proxy_no_cache $do_not_cache;

    }

    location ~* \.(jpg|png|gif|jpeg|css|js|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx)$ {
            proxy_cache_valid 200 120d;
            expires 364d;
            add_header Cache-Control public;
            proxy_pass http://127.0.0.1:8000;
            proxy_cache staticfilecache;
            add_header X-Nginx-Cache-Status $upstream_cache_status;
            proxy_cache_use_stale  error timeout invalid_header updating http_500 http_502 http_503 http_504;
    }
nginx
  • 3 个回答
  • 15910 Views
Martin Hope
Quintin Par
Asked: 2012-09-28 08:52:04 +0800 CST

在 nginx 中检测 Slashdot 效果

  • 10

有没有办法让 Nginx 在来自推荐人的点击量超过阈值时通知我?

例如,如果我的网站在 Slashdot 上有特色,并且突然间我在一小时内有 2K 的点击量,我想在一小时的点击量超过 1K 时收到通知。

是否可以在 Nginx 中执行此操作?可能没有lua?(因为我的产品不是lua编译的)

nginx
  • 4 个回答
  • 826 Views
Martin Hope
Quintin Par
Asked: 2012-08-25 03:35:52 +0800 CST

Puppet:获取用户主目录

  • 13

我正在创建一个用户如下

user { $username:
    comment => "$name",
    shell   => "$shell",
    managehome => false,
    password  => "$password",
    groups => $groups
}

现在你可以看到我正在做一个 managehome is false 现在稍后我需要将文件推送到用户的主目录。

$key = "${homedir}/${name}/file"

    file { $key:
    ensure => present,
    owner  => $username,
    group  => $username,
    mode   => 600,
    content => "$keyvalue",
    subscribe => User[$username],
}

我怎样才能得到用户的主目录呢?

linux
  • 4 个回答
  • 10934 Views
Martin Hope
Quintin Par
Asked: 2012-08-23 22:34:24 +0800 CST

由于 Date::Manip 问题无法运行 logwatch

  • 5

我试着在下面运行 logwatch

[root@machine cron.daily]# ./0logwatch 
ERROR: Date::Manip unable to determine TimeZone.

Execute the following command in a shell prompt:
        perldoc Date::Manip
The section titled TIMEZONES describes valid TimeZones
and where they can be defined.

我的日期如下

root@machine cron.daily]# date
Thu Aug 23 06:25:21 GMT 2012

现在根据各种论坛中的详细信息,我尝试通过设置来解决此问题

/etc/timezone to “+0800”

但它没有用

我/etc/localtime指向/usr/share/zoneinfo/GMT 并由puppet管理

我该如何解决这个问题?我仍然希望我所有的机器都在 GMT 时区。

编辑:
遗憾的是,
这两项更改均无效:

[root@machine cron.daily]# cat /etc/TIMEZONE 
UTC

广达的

[root@machine cron.daily]# cat ~/.bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
export TZ=GMT

export PATH
[root@machine cron.daily]# source ~/.bash_profile
[root@machine cron.daily]# ./0logwatch 
ERROR: Date::Manip unable to determine TimeZone.

Execute the following command in a shell prompt:
        perldoc Date::Manip
The section titled TIMEZONES describes valid TimeZones
and where they can be defined.
linux
  • 3 个回答
  • 3036 Views
Martin Hope
Quintin Par
Asked: 2012-08-21 22:50:43 +0800 CST

阻止来自 EC2 的所有请求

  • 3

我想阻止所有来自EC2机器的对我的网络服务器的请求。

我可以使用基于 Ec2 的虚拟机的 IP 地址/网络公共列表吗?

amazon-ec2
  • 1 个回答
  • 227 Views
Martin Hope
Quintin Par
Asked: 2012-08-08 10:33:42 +0800 CST

设置 Puppet 以通过电子邮件发送失败报告 [重复]

  • 1
这个问题在这里已经有了答案:
9 年前关闭。

可能重复:
警告失败的 Puppet 状态

如何设置 Puppet 将失败的报告通过电子邮件发送到某个地址?

我已经puppet.conf这样设置了

[master]
    server = puppet.site.net
[main]
    #dns_alt_names = puppet.site.net
    report = true
    #pluginsync = true
    # The Puppet log directory.
    # The default value is '$vardir/log'.
    logdir = /var/log/puppet

    # Where Puppet PID files are kept.
    # The default value is '$vardir/run'.
    rundir = /var/run/puppet

    # Where SSL certificates are kept.
    # The default value is '$confdir/ssl'.
    ssldir = $vardir/ssl

[agent]
    # The file in which puppetd stores a list of the classes
    # associated with the retrieved configuratiion.  Can be loaded in
    # the separate ``puppet`` executable using the ``--loadclasses``
    # option.
    # The default value is '$confdir/classes.txt'.
    classfile = $vardir/classes.txt

    # Where puppetd caches the local configuration.  An
    # extension indicating the cache format is added automatically.
    # The default value is '$confdir/localconfig'.
    localconfig = $vardir/localconfig

我看过一个帖子。但它适用于一切。

我只需要失败。在主人和客户上。
有人可以帮助我进行有效的会议和设置吗?

puppet
  • 1 个回答
  • 567 Views
Martin Hope
Quintin Par
Asked: 2012-08-07 02:46:44 +0800 CST

使用 puppet 更改 ip route 和 sysctl

  • 7

我有两个更改ip route&sysctl禁用 tcp 慢启动。我是这样做的

ip route show

记下以 default 开头的行。

从默认行中获取 IP 并运行

sudo ip route change default via $ip_address dev eth0 initcwnd 12 
sudo sysctl -w net.ipv4.tcp_slow_start_after_idle=0

我怎样才能从中创建一个人偶脚本?一款可以部署到多台同类型机器上的——CentOS 6

编辑: 添加赏金以获得工作示例

sudo ip route change default via $ip_address dev eth0 initcwnd 12 
linux
  • 3 个回答
  • 4524 Views
Martin Hope
Quintin Par
Asked: 2012-07-28 19:55:26 +0800 CST

Rsync 备份:校验和不匹配

  • 1

虽然我对此有点困惑

diff –rq  dir/ dir1/ 

没有区别 这个rsync是备份目录

rsync -avrREz --delete --links -e "ssh -l user" --delete dir/ site.net:dir/ && tar -c /dir/ | md5sum

但是当我在目标目录上执行 tar 时,它似乎没有给我相同的校验和

tar –c dir/ | md5sum

我错过了什么吗?

linux
  • 1 个回答
  • 362 Views
Martin Hope
Quintin Par
Asked: 2010-01-30 19:20:07 +0800 CST

如果我要迁移到云端,我应该谨慎寻找/谨慎行事

  • 3

迁移到像 Rackspace 这样的云时我应该注意什么?serverfault 的另一位用户遇到了计算周期 (CC) 爆炸等问题,我不想有同样的体验。

cloud-computing hosting cloud rackspace
  • 2 个回答
  • 189 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