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

Greg Dubicki's questions

Martin Hope
Greg Dubicki
Asked: 2016-10-19 06:58:33 +0800 CST

Nginx add_header 在我的位置块之一中不起作用?

  • 5

我使用 nginx 1.10.1 的配置类似于:

server {

    (...)

    add_header Header1 "value";

    (...)

    # in this location above add_header directive works
    location / {
         uwsgi_pass unix:/var/run/some.sock;

         (...)
    }

    # ..and it this one it doesn't!
    location ~* (^/$|favicon.ico|robots.txt) {
        return 204;
        expires 24h;
        add_header Cache-Control "public";
        etag on;
    }
}

..所以我的问题是 Header1 是为第一个位置处理的请求设置的,但不是为第二个位置处理的请求。

为什么?

我已阅读add_header文档并知道它默认情况下仅适用于“正”返回码,但 204 是其中之一(我实际上已经测试过将代码更改为 200、404 并没有帮助)。

(我也尝试添加always到我的add_header Header1 ...,但这是一个相当绝望的尝试,因为它不应该帮助 - 它没有。)

nginx http-headers
  • 1 个回答
  • 2684 Views
Martin Hope
Greg Dubicki
Asked: 2016-09-09 03:49:09 +0800 CST

普通 shell vs subshel​​l vs "bash -c" last command exit code

  • 7

我正在尝试正确链接&&最后一个命令的退出代码。||

我遇到了一个我无法解释的奇怪行为。请帮忙。

这是我的exit-code.sh测试脚本:

#!/bin/bash
echo "running exit-code with $1"
exit $1

这按预期工作:

$ ./exit-code.sh 1 && ./exit-code.sh 2 && ./exit-code.sh 3 || echo last exit code: $?
running exit-code with 1
last command exit code: 1

在()子shell中运行它也是如此:

$ (./exit-code.sh 1 && ./exit-code.sh 2 && ./exit-code.sh 3 || echo last exit code: $?)
running exit-code with 1
last exit code: 1

但:

$ /bin/bash -c "./exit-code.sh 1 && ./exit-code.sh 2 && ./exit-code.sh 3 || echo last exit code: $?"
running exit-code with 1
last exit code: 0

为什么我在这里得到退出代码 0?

bash shell
  • 2 个回答
  • 2051 Views
Martin Hope
Greg Dubicki
Asked: 2015-02-04 04:14:28 +0800 CST

Apache Kafka 0.8.1.1 干净关闭不起作用

  • 1

我有一个:

  • 使用默认配置(server.properties等)从源安装的 Apache Kafka(2.9.2-0.8.1.1)的单个实例,
  • Zookeeper (3.4.5+dfsg-2) 单机,从包中安装

..在 Ubuntu 14.04 LTS 主机上运行,​​名称为hostname1.


我尝试干净地关闭 Kafka,但我不能。


我尝试了两种方法:

  • 发送 SIGINT - 但 Kafka 只是忽略它(没有提到在任何日志中接收信号,继续运行)[SIGTERM 有效,但这不是重点]

  • 使用受控关机工具- 但它失败了以下..

..堆栈跟踪:

[2015-02-03 12:55:49,461] ERROR Operation failed due to controller failure (kafka.admin.ShutdownBroker$)
java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: hostname1; nested exception is:
        java.net.ConnectException: Connection refused]
        at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:369)
        at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:268)
        at kafka.admin.ShutdownBroker$.kafka$admin$ShutdownBroker$$invokeShutdown(ShutdownBroker.scala:56)
        at kafka.admin.ShutdownBroker$.main(ShutdownBroker.scala:109)
        at kafka.admin.ShutdownBroker.main(ShutdownBroker.scala)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: hostname1; nested exception is:
        java.net.ConnectException: Connection refused]
        at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:118)
        at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:203)
        at javax.naming.InitialContext.lookup(InitialContext.java:411)
        at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1929)
        at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1896)
        at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:286)
        ... 4 more
Caused by: java.rmi.ConnectException: Connection refused to host: hostname1; nested exception is:
        java.net.ConnectException: Connection refused
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
        at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
        at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
        at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:341)
        at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
        at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:114)
        ... 9 more
Caused by: java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:579)
        at java.net.Socket.connect(Socket.java:528)
        at java.net.Socket.<init>(Socket.java:425)
        at java.net.Socket.<init>(Socket.java:208)
        at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
        at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:147)
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
        ... 14 more 
apache-2.2
  • 2 个回答
  • 1517 Views
Martin Hope
Greg Dubicki
Asked: 2015-01-31 14:12:48 +0800 CST

如何从实例中列出 EC2 安全组 *rules*?

  • 2

我对 EC2 实例具有 SSH 根访问权限,但无法访问 AWS 控制台/AWS KEY & SECRET。


我在除 22 TCP 之外的所有 TCP 端口上到此主机的传入流量似乎都被阻止了 - 我无法nginx从外部访问我的服务(例如在端口 80 上)。

nmap将这些端口显示为filtered,而当 SSH 运行和closedSSH 暂时关闭时,端口 22 显示为打开。


ICMP 和 UDP 也被阻止。

(我使用ping,nc和其他一些工具来检查。)


我知道我的实例位于某个自定义的、非默认的 EC2 安全组中,比如说my-security-group,但我不知道它的规则。


如何使用我拥有的访问级别列出这些规则?


更新 1:我的iptables规则是空的 - 假设我确定它是阻止我的流量的安全组。

amazon-ec2
  • 1 个回答
  • 871 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