【问题标题】:Apache2 - 400 bad request while accessing using docker service name but works with IP addressApache2 - 使用 docker 服务名称访问但使用 IP 地址时出现 400 错误请求
【发布时间】:2020-06-17 10:29:16
【问题描述】:

我正在使用docker stack deploy 部署堆栈。在这个堆栈中有 nginx 作为反向代理和 apache2 作为后端服务器。

现在,如果我使用 curl -v http://service_name:8888 从其他容器访问我的 apache2 容器,它会返回 400 bad request 错误。但是,如果我尝试 curl -v 10.0.9.7:8888 它可以使用 200 个成功代码。

我无法确定错误在哪里。

000-default.conf

<VirtualHost *:*>
  ServerAdmin admin@sa.com
  DocumentRoot "/var/www/site"

  ServerName r.sa.com
  <Directory /var/www/site>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order deny,allow
      Allow from all
  </Directory>

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

ports.conf

Listen 8888
Listen 8889

<IfModule ssl_module>
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

error.log

/var/log/apache2/error.log 
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.0.0.9. Set the 'ServerName' directive globally to suppress this message
[Thu Mar 05 07:17:41.921722 2020] [mpm_prefork:notice] [pid 8] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Thu Mar 05 07:17:41.922504 2020] [core:notice] [pid 8] AH00094: Command line: '/usr/sbin/apache2 -D FOREGROUND'

【问题讨论】:

  • "400 bad request error" 似乎service_name:8888 被某些使用 SSL 的服务处理并在请求中接收纯文本。你能添加一些日志吗?。
  • @matiferrigno 添加了 apache 的 error.log
  • 能否在两者都进行 curl 的时间间隔内添加 apache 和 nginx 反向代理日志的访问/错误日志?
  • 你也可以添加到 stack.yml 吗?

标签: docker docker-swarm apache2.4


【解决方案1】:

Apache 阻止使用下划线(“_”)作为主机名的 HTTP 请求。如果您将服务名称更改为“服务名称”,它将起作用。

参考:https://ma.ttias.be/apache-httpd-2-2-15-60-underscores-hostnames-now-blocked/

【讨论】:

    猜你喜欢
    • 2013-11-27
    • 2015-12-14
    • 1970-01-01
    • 2013-09-27
    • 2015-08-18
    • 2015-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多